angular-socket-io icon indicating copy to clipboard operation
angular-socket-io copied to clipboard

Require.JS ??

Open sombodi opened this issue 10 years ago • 3 comments

Anyone know how to use this with requirejs? I am having some trouble bootsraping it in

sombodi avatar Dec 15 '15 18:12 sombodi

+1

Steve-Mc avatar Jan 29 '16 12:01 Steve-Mc

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);
                }
            })
        })
    }
}

bailinx avatar Feb 16 '16 09:02 bailinx

Awesome, works perfectly, thanks!

sombodi avatar Feb 24 '16 17:02 sombodi