$ npm i -S smashcast-ws
import smashcastWs from 'smashcast-ws';
smashcastWs.sendMessage('service.method', data);
Register
smashcastWs.on('service.method', callback);
Unregister
smashcastWs.off('service.method', callback);
Register
const observable$ = smashcastWs.observe('service.method');
const subscription = observable$.subscribe(callback);
Unregister
subscription.unsubscribe();
smashcastWs.on('open', callback);
If you send a message when WS is not connected, the message will be sent when the connection is ready again
smashcastWs.sendMessage('service.method', {});
smashcastWs.sendMessage('method', {});
smashcastWs.on('method', callback);