Created
May 2, 2014 13:00
-
-
Save rosterloh/a32f2b1362719527354c to your computer and use it in GitHub Desktop.
The world's most basic socket.io AngularJS factory
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
appServices.factory('socket', function ($rootScope) { | |
var socket = io.connect('http://localhost:3000'); | |
return { | |
on: function (eventName, callback) { | |
socket.on(eventName, function () { | |
var args = arguments; | |
$rootScope.$apply(function () { | |
callback.apply(socket, args); | |
}); | |
}); | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment