diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-05-30 03:54:53 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-07-12 01:25:54 +0800 |
commit | af395eccda95f12ba14f40f9261443d24e48f455 (patch) | |
tree | 0fee2323cdba4efefcfebf7152aa0d5552ef3258 /packages/connect/src | |
parent | c403dcdabf4b98ea0ecde1ab0e7e9dafa97d797f (diff) | |
download | dexon-0x-contracts-af395eccda95f12ba14f40f9261443d24e48f455.tar.gz dexon-0x-contracts-af395eccda95f12ba14f40f9261443d24e48f455.tar.zst dexon-0x-contracts-af395eccda95f12ba14f40f9261443d24e48f455.zip |
Update orderbook channel and factory tests
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; } |