aboutsummaryrefslogtreecommitdiffstats
path: root/packages/connect/src
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-05-30 03:54:53 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-07-12 01:25:54 +0800
commitaf395eccda95f12ba14f40f9261443d24e48f455 (patch)
tree0fee2323cdba4efefcfebf7152aa0d5552ef3258 /packages/connect/src
parentc403dcdabf4b98ea0ecde1ab0e7e9dafa97d797f (diff)
downloaddexon-sol-tools-af395eccda95f12ba14f40f9261443d24e48f455.tar
dexon-sol-tools-af395eccda95f12ba14f40f9261443d24e48f455.tar.gz
dexon-sol-tools-af395eccda95f12ba14f40f9261443d24e48f455.tar.bz2
dexon-sol-tools-af395eccda95f12ba14f40f9261443d24e48f455.tar.lz
dexon-sol-tools-af395eccda95f12ba14f40f9261443d24e48f455.tar.xz
dexon-sol-tools-af395eccda95f12ba14f40f9261443d24e48f455.tar.zst
dexon-sol-tools-af395eccda95f12ba14f40f9261443d24e48f455.zip
Update orderbook channel and factory tests
Diffstat (limited to 'packages/connect/src')
-rw-r--r--packages/connect/src/orderbook_channel_factory.ts14
-rw-r--r--packages/connect/src/types.ts2
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;
}