$rootScope.$on('$stateChangeStart', function(event, toState) {
pubnub.unsubscribe({
channel : ["examplechannel1", "examplechannel2"]
});
});
When I navigate to another page, $stateChangeStart detects it and runs pubnub.unsubscribe
, a synchronous XHR function (I think). This causes a delay of anywhere from 0.5s to 3s depending on network congestion. How can I eliminate this delay by changing the state immediately and running the unsubscribe function asynchronously?