IguMail/socketio-shared-webworker

Suggestions of improvements

icaroscherma opened this issue · 2 comments

I understand the idea of console.loging everything, but only in devMode, would be nice to have a (boolean) var devMode = false that if you turn on, it will output console logs...

Would be nice to suggest an implementation like this (support safari/ie-edge ):

var socket;
if (typeof(window.SharedWorker) === 'undefined') {
  socket = io('http://localhost:50180/fiep-crm');
} else {
  socket = wio('http://localhost:50180/fiep-crm');
  socket.setWorker('js/shared-worker.js');
}

and with this, suggest the user not to use send(msg), only emit('message', msg).

I was struggling doing some code (based in an article that you based your work here) trying to send a message (send()), but this seems far better, I'm only worried that since it doesn't use the socket.io's lib, that it may get outdated...

Thanks for the feedback!

Yes, console.log will go and yes, only available in dev mode.

support safari/ie-edge

  • if you would like to submit a PR for that, I'd be grateful.

I'm only worried that since it doesn't use the socket.io's lib, that it may get outdated...

It does use socket.io. It's a dependency and will be updated whenever you do a fresh npm install or npm update
https://github.com/IguMail/socketio-shared-webworker/blob/master/package.json#L28

I meant your core implementation kind of extends it not only include it, so with major updates it comes API deprecation...
It would be nicer if the client-side Socket.io would support plugins/middlewares, and your implementation would be used as a plugin/middleware, like server-side has use()...