I am adding some websocket functional to our angular app. The Websocket object is wrapped in a service. Ideally we would like our wrapped socket object to have a standard event API so that we can use it in the controller like the following: (Sorry for the Coffeescript)
angular.module('myApp').controller 'myCtrl', ($scope, socket) ->
update = (msg)->
$scope.apply ->
#do something regarding to the msg
socket.on 'message', update
unregister: ->
socket.off 'message', update
What's the best practice/library for us to achieve this? Use jquery? Backbone.Events? Any suggestion will be helpful. Thanks!