angular / ngSocket

WebSocket support for angular
Apache License 2.0
204 stars 25 forks source link

ngWebSocket should be consistent with $http in calling $digest/$apply. #4

Closed baalexander closed 10 years ago

baalexander commented 10 years ago

After receiving data from over the WebSocket, it would be great if the service also called $digest/$apply. At least, similar to what $http is doing.

lord2800 commented 10 years ago

On the one hand, I agree that symmetry is good. On the other hand, depending on how frequently you pulse data through a socket (think: realtime chat), $digest/$apply might get really expensive for no good reason. Perhaps an option to enable or disable auto $digest?

jeffbcross commented 10 years ago

Mr. @btford and I discussed it and think that listeners that handle data from the server should apply by default, but take an options object that can specify autoApply: false. E.g.

mySocket.onMessage(
    function() {...},
    {autoApply: false});