functionhandleTickersUpdate(message: KatanaPerpsTickerEventData) { // handle the updated data console.log('Ticker: ', message); }
client.onMessage((message: KatanaPerpsMessageEvent) => { 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 KatanaPerps<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.KatanaPerps<name>Eventinterface will document its provideddatashape and properties.subscriptionsproperty when dispatched.See
data KatanaPerpsOrderBookLevel2EventData