diff options
Diffstat (limited to 'packages/connect/src')
-rw-r--r-- | packages/connect/src/orderbook_channel_factory.ts | 14 | ||||
-rw-r--r-- | packages/connect/src/types.ts | 2 |
2 files changed, 11 insertions, 5 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 => { diff --git a/packages/connect/src/types.ts b/packages/connect/src/types.ts index d7d7a96d0..7347beb0b 100644 --- a/packages/connect/src/types.ts +++ b/packages/connect/src/types.ts @@ -11,7 +11,7 @@ export interface Client { } export interface OrderbookChannel { - subscribe: (subscriptionOpts: OrderbookChannelSubscriptionOpts, handler: OrderbookChannelHandler) => void; + subscribe: (subscriptionOpts: OrderbookChannelSubscriptionOpts) => void; close: () => void; } |