functionhandleTickersUpdate(message: KumaTickerEventData) { // handle the updated data console.log('Ticker: ', message); }
client.onMessage((message: KumaMessageEvent) => { switch (message.type) { caseMessageEventType.error: console.error( `[${message.data.code}] | Error received from WebSocketServer: ${message.data.message}`, ); break; caseMessageEventType.subscriptions: returnhandleSubscriptions(message.subscriptions); // narrows the type to the specific Kuma<name>Event type caseMessageEventType.tickers: returnhandleTickersUpdate(message.data); default: break; } });
subscription
Websocket messages always include a type property which dictates the shape of itsdata
property.type
will be the name of the subscription that the message correlates to.Kuma<name>Event
interface will document its provideddata
shape and properties.subscriptions
property when dispatched.See
data KumaOrderBookLevel2EventData