When we are having and ajax call in jquery we can write it this way:
$.ajax({
url: 'http://localhost/url',
type: 'GET',
dataType: "json",
data: {name : "data"},
beforeSend : function(){
...
},
success:function(data)
{
...
},
error : function(){
...
}
}
});
Is this declaration template/style can also be applied to socket event handling in Socket.IO?
Can we do something like:
var socket = io.connect( );
socket.on({
'connect' : function(){
...
},
'error' : function(){
...
},
'my custom event' : function(){
...
}
}
)
Thanks!