Skip to content

Socket has hardcoded "message" event #9

@graforlock

Description

@graforlock

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions