Skip to content

Instantly share code, notes, and snippets.

@TomKaltz
Created March 5, 2014 19:11
Show Gist options
  • Save TomKaltz/31a9e48dfb183efc0fa3 to your computer and use it in GitHub Desktop.
Save TomKaltz/31a9e48dfb183efc0fa3 to your computer and use it in GitHub Desktop.
'use strict';
angular.module('SomeApp')
.service('Realtimeposts', function Realtimeposts($http, socketFactory) {
var socket = socketFactory();
var allposts = [];
var onNewrealtimepost = function(data){
allposts.push(data);
};
var subscribetorealtime = function (){
socket.on('newrealtimepost', onNewrealtimepost);
};
subscribetorealtime();
return {
stop: function(){
//this does not work
socket.removeListener('newrealtimepost', onNewrealtimepost);
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment