-
-
Save TomKaltz/31a9e48dfb183efc0fa3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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