Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to implement callback in ngHistory in Pubnub? #5

Open
rinirinku opened this issue Aug 12, 2014 · 2 comments
Open

How to implement callback in ngHistory in Pubnub? #5

rinirinku opened this issue Aug 12, 2014 · 2 comments

Comments

@rinirinku
Copy link

When trying to retrieve the history message in the on event , the loading time is too long. The spinner show and hides too fast. But the message is not yet loaded.

How can we calculate or get the exact time to make the history load?
$scope.limit = 100
PubNub.ngHistory( {
channel : $scope.channel,
limit : $scope.limit
});

$rootScope.$on(PubNub.ngMsgEv($scope.channel), function(ngEvent, payload) {

            **ActivityIndicator.showSpinner();**

                $scope.$apply(function(){
                $scope.messages.push(payload.message);
            });

            $(".messages-wrap").scrollTop($(".messages-wrap")[0].scrollHeight);
            **ActivityIndicator.hideSpinner();**

        }); 
@PatrickJS
Copy link

couldn't you just use the callback?

PubNub.ngHistory( {
  channel : $scope.channel,
  limit : $scope.limit,
  callback: $scope.callback
});

@sunnygleason
Copy link
Contributor

@rinirinku @gdi2290 the callback isn't exposed via angular - I've taken on a TODO item though to expose it in an upcoming version -- stay tuned!

In the meantime, you could call history via PubNub.jsapi.history(), although this bypasses the angular scope broadcast since it's going against the PUBNUB object directly under the hood.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants