WebSocketBundle
WebSocketBundle copied to clipboard
multiple socket/connect event race condition?
My app subscribes to 2 different topics. However the second one is a little below in the code.
I suspect, time to time the second event doesn't register before connect, so it doesn't run.
It seems ab.connect gets the connect callback as a parameter but ws.connect doesn't. It's set with the on method.
What is the safest way to register multiple connect events callbacks and ensure that they register before the connect happens and they run?
Thanks
Here is a sample code var websocket = WS.connect("ws://localhost:8080");
websocket.on("socket/connect", function(session){ console.log('running'); });
/// .... SOME OTHER CODE
websocket.on("socket/connect", function(session){ console.log('Sometimes not running'); });