Skip to content

Instantly share code, notes, and snippets.

@Kuirak
Last active August 29, 2015 14:00
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kuirak/11377550 to your computer and use it in GitHub Desktop.
Save Kuirak/11377550 to your computer and use it in GitHub Desktop.
$sailsSocket.subscribe('event',function(message){
if(message.verb ==='created'){
$scope.events.push(message.data);
}
});
$sailsSocket.get('/api/event/subscribe').success(function(data){
console.log("Subscribed")
});
$sailsSocket.get('/api/event').success(function(data){
$scope.events =data;
}).error(function(err){
$scope.error =err;
});
module.exports = {
subscribe:function(req,res){
"use strict";
if(req.isSocket) {
Event.watch(req.socket);
res.end(200);
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment