diff options
Diffstat (limited to 'packages/connect/src/orderbook_channel_factory.ts')
-rw-r--r-- | packages/connect/src/orderbook_channel_factory.ts | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/packages/connect/src/orderbook_channel_factory.ts b/packages/connect/src/orderbook_channel_factory.ts index 1b5625840..5134af323 100644 --- a/packages/connect/src/orderbook_channel_factory.ts +++ b/packages/connect/src/orderbook_channel_factory.ts @@ -1,21 +1,27 @@ import * as WebSocket from 'websocket'; -import { OrderbookChannel } from './types'; +import { OrderbookChannel, OrderbookChannelHandler } from './types'; import { assert } from './utils/assert'; import { WebSocketOrderbookChannel } from './ws_orderbook_channel'; export const orderbookChannelFactory = { /** * Instantiates a new WebSocketOrderbookChannel instance - * @param url The relayer API base WS url you would like to interact with + * @param url The relayer API base WS url you would like to interact with + * @param handler An OrderbookChannelHandler instance that responds to various + * channel updates * @return An OrderbookChannel Promise */ - async createWebSocketOrderbookChannelAsync(url: string): Promise<OrderbookChannel> { + async createWebSocketOrderbookChannelAsync( + url: string, + handler: OrderbookChannelHandler, + ): Promise<OrderbookChannel> { assert.isUri('url', url); + assert.isOrderbookChannelHandler('handler', handler); return new Promise<OrderbookChannel>((resolve, reject) => { const client = new WebSocket.w3cwebsocket(url); client.onopen = () => { - const orderbookChannel = new WebSocketOrderbookChannel(client); + const orderbookChannel = new WebSocketOrderbookChannel(client, handler); resolve(orderbookChannel); }; client.onerror = err => { |