Unable to subscribe from a topic.
Closed this issue · 1 comments
sachingorade commented
I have following code in my app.js,
$scope.subscribeTopic = function() {
$scope.subscription = $wamp.subscribe($scope.topic, function(args, kwargs, details){
console.log(update);
});
}
$scope.unsubscribeTopic = function() {
$scope.subscription.unsubscribe();
}
unsubscribeTopic method is tied to a buttton, but when I click on this button I get following error message,
TypeError: $scope.subscription.unsubscribe is not a function
at a.$$childScopeClass.$$childScopeClass.$scope.unsubscribeTopic (app.js:51)
at angular.js:10847
at f (angular.js:19136)
at a.$$childScopeClass.$$childScopeClass.$eval (angular.js:12702)
at a.$$childScopeClass.$$childScopeClass.$apply (angular.js:12800)
at HTMLButtonElement.<anonymous> (angular.js:19141)
at HTMLButtonElement.dispatch (jquery-min.js:3)
at HTMLButtonElement.i (jquery-min.js:3)
(anonymous) @ angular.js:10072
(anonymous) @ angular.js:7364
$apply @ angular.js:12802
(anonymous) @ angular.js:19141
dispatch @ jquery-min.js:3
i @ jquery-min.js:3
am I doing something wrong?
EDIT
I tried with following code as well,
$scope.unsubscribeTopic = function() {
$wamp.unsubscribe($scope.subscription);
}
but then I get following error,
TypeError: a.unsubscribe is not a function
at angular-wamp.min.js:1
at angular-wamp.min.js:1
at F (angular.js:11573)
at angular.js:11659
at k.$eval (angular.js:12702)
at k.$digest (angular.js:12514)
at a.$$childScopeClass.$$childScopeClass.$apply (angular.js:12806)
at HTMLButtonElement.<anonymous> (angular.js:19141)
at HTMLButtonElement.dispatch (jquery-min.js:3)
at HTMLButtonElement.i (jquery-min.js:3)
(anonymous) @ angular.js:10072
(anonymous) @ angular.js:7364
F @ angular.js:11576
(anonymous) @ angular.js:11659
$eval @ angular.js:12702
$digest @ angular.js:12514
$apply @ angular.js:12806
(anonymous) @ angular.js:19141
dispatch @ jquery-min.js:3
i @ jquery-min.js:3
angular.js:10072 $wamp error Object {type: "unsubscribe", arguments: Arguments[1], error: TypeError: a.unsubscribe is not a function
at http://localhost:8080/myapp/resources/js/an…}
davidwdan commented
The Subscription
is a promise. See #50 (comment)