PubNub AngularJS service fires repeatedly

…衆ロ難τιáo~ 提交于 2019-12-24 06:47:42

问题


I have the following event listener in my AngularJS Controller (as shown in the PubNub SDK docs) that fires multiple times on one message if the browser is refreshed after the message comes in.

But the data is empty after the original call to Pubnub.getMessageEventNameFor() so besides for just checking data (which seems like a hack covering up another issue), how/why is this function being repeatedly called?

$scope.$on(Pubnub.getMessageEventNameFor($scope.myChannel), function(ngEvent, data) {
    $scope.$apply(function() {
        processMessage(data.message);
    });
});

Is there a way to prevent this listener from firing multiple times?

UPDATE: The multiple fires are each associated with a previous message, as opposed to multiple firings of the same message. This is sounding more and more like an Pubnub AngularJS SDK issue.

来源:https://stackoverflow.com/questions/42440256/pubnub-angularjs-service-fires-repeatedly

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!