functionhandleTickersUpdate(message: IDEXTickerEventData) { // handle the updated data console.log('Ticker: ', message); }
client.onMessage((message: IDEXMessageEvent) => { 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 IDEX<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.IDEX<name>Event
interface will document its provideddata
shape and properties.subscriptions
property when dispatched.See
enum MessageEventType