cWS icon indicating copy to clipboard operation
cWS copied to clipboard

Overriding .onmessage triggers "cWS does not support multiple listeners"

Open Rush opened this issue 5 years ago • 2 comments

I wanted to handle first message differently then the rest:

const messageHandler = message => {
        handleDifferently(message);
        ws.onmessage = anotherMessageHandler;
      };
      ws.onmessage = messageHandler;
cWS does not support multiple listeners for the same event. Old listener for 'message' event will be overwritten

Expected: no warning issued

Rush avatar Aug 01 '20 03:08 Rush

This is just a warning informing you about switch of the listener unfortunately there is no way to disable that at the moment.

goriunov avatar Aug 02 '20 08:08 goriunov

Correct - I understand it's a minor issue. Reporting it nonetheless.

Rush avatar Aug 02 '20 17:08 Rush