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; } });
subscriptionWebsocket messages always include a type property which dictates the shape of itsdataproperty.typewill be the name of the subscription that the message correlates to.Kuma<name>Eventinterface will document its provideddatashape and properties.subscriptionsproperty when dispatched.See