I believe Socket.on is not generic enough, as it stand now it is:
let on = (socket, func) =>
_on(socket, "message", obj => func(Json.fromValidJson(obj)));
But looking at the docs Socket.IO Documentation, socket.io should support different types of events:
io.on('connection', function(socket){
socket.emit('request', /* */); // emit an event to the socket
io.emit('broadcast', /* */); // emit an event to all connected sockets
socket.on('reply', function(){ /* */ }); // listen to the event
});
So the above would be like this:
let on = (socket, event, func) =>
_on(socket, event, obj => func(Json.fromValidJson(obj)));
The design decision here is however to support switch statement match; shouldn't user have option to do it the standard way through optional parameter?
I believe Socket.on is not generic enough, as it stand now it is:
But looking at the docs Socket.IO Documentation, socket.io should support different types of events:
So the above would be like this:
The design decision here is however to support switch statement match; shouldn't user have option to do it the standard way through optional parameter?