angular-socket-io
angular-socket-io copied to clipboard
Require.JS ??
Anyone know how to use this with requirejs? I am having some trouble bootsraping it in
+1
I also encountered this problem, that is the problem of their own projects, a waste of two days.
My solution is (look at my project)
var socket = io.connect();
return {
on: function (eventName, callback) {
socket.on(eventName, function () {
var args = arguments;
$rootScope.$apply(function () {
callback.apply(socket, args);
})
})
},
emit: function (eventName, data, callback) {
socket.emit(eventName, data, function () {
var args = arguments;
$rootScope.$apply(function () {
if( callback ) {
callback.apply(socket, args);
}
})
})
}
}
Awesome, works perfectly, thanks!