diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-21 01:10:25 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-21 01:10:25 +0800 |
commit | 856a5c3369c0248ec32924b25ec77dce6b4e1071 (patch) | |
tree | b1a6219a2e7ac2c1673086c176b2346020351aae /packages/0x.js/src | |
parent | 2c193a1244d9f288c7c01142d42e442a687ce114 (diff) | |
download | dexon-sol-tools-856a5c3369c0248ec32924b25ec77dce6b4e1071.tar dexon-sol-tools-856a5c3369c0248ec32924b25ec77dce6b4e1071.tar.gz dexon-sol-tools-856a5c3369c0248ec32924b25ec77dce6b4e1071.tar.bz2 dexon-sol-tools-856a5c3369c0248ec32924b25ec77dce6b4e1071.tar.lz dexon-sol-tools-856a5c3369c0248ec32924b25ec77dce6b4e1071.tar.xz dexon-sol-tools-856a5c3369c0248ec32924b25ec77dce6b4e1071.tar.zst dexon-sol-tools-856a5c3369c0248ec32924b25ec77dce6b4e1071.zip |
Throw when subscription is already present
Diffstat (limited to 'packages/0x.js/src')
-rw-r--r-- | packages/0x.js/src/order_watcher/expiration_watcher.ts | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/packages/0x.js/src/order_watcher/expiration_watcher.ts b/packages/0x.js/src/order_watcher/expiration_watcher.ts index acc7e7e5d..6d9556336 100644 --- a/packages/0x.js/src/order_watcher/expiration_watcher.ts +++ b/packages/0x.js/src/order_watcher/expiration_watcher.ts @@ -2,7 +2,7 @@ import * as _ from 'lodash'; import {BigNumber} from 'bignumber.js'; import {utils} from '../utils/utils'; import {intervalUtils} from '../utils/interval_utils'; -import {SignedOrder} from '../types'; +import {SignedOrder, ZeroExError} from '../types'; import {Heap} from '../utils/heap'; import {ZeroEx} from '../0x'; @@ -26,6 +26,9 @@ export class ExpirationWatcher { this.orderHashHeapByExpiration = new Heap(scoreFunction); } public subscribe(callback: (orderHash: string) => void): void { + if (!_.isUndefined(this.callbackIfExists)) { + throw new Error(ZeroExError.SubscriptionAlreadyPresent); + } this.callbackIfExists = callback; this.orderExpirationCheckingIntervalIdIfExists = intervalUtils.setAsyncExcludingInterval( this.pruneExpiredOrders.bind(this), this.orderExpirationCheckingIntervalMs, |