diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-29 04:27:16 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-29 04:27:16 +0800 |
commit | e4dfdc6b5c9073470ef7f70325d013ec20c7da96 (patch) | |
tree | 8f7f20a3b9336249c298057a20d6985427b52191 | |
parent | 9e673f0073b9e6c58256df88bd2d061593a6b1bc (diff) | |
download | dexon-sol-tools-e4dfdc6b5c9073470ef7f70325d013ec20c7da96.tar dexon-sol-tools-e4dfdc6b5c9073470ef7f70325d013ec20c7da96.tar.gz dexon-sol-tools-e4dfdc6b5c9073470ef7f70325d013ec20c7da96.tar.bz2 dexon-sol-tools-e4dfdc6b5c9073470ef7f70325d013ec20c7da96.tar.lz dexon-sol-tools-e4dfdc6b5c9073470ef7f70325d013ec20c7da96.tar.xz dexon-sol-tools-e4dfdc6b5c9073470ef7f70325d013ec20c7da96.tar.zst dexon-sol-tools-e4dfdc6b5c9073470ef7f70325d013ec20c7da96.zip |
Add ifExists to cleanupJobInterval
-rw-r--r-- | packages/0x.js/src/order_watcher/order_state_watcher.ts | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/packages/0x.js/src/order_watcher/order_state_watcher.ts b/packages/0x.js/src/order_watcher/order_state_watcher.ts index 91a35c4ae..bf80fc00a 100644 --- a/packages/0x.js/src/order_watcher/order_state_watcher.ts +++ b/packages/0x.js/src/order_watcher/order_state_watcher.ts @@ -71,7 +71,7 @@ export class OrderStateWatcher { private _orderFilledCancelledLazyStore: OrderFilledCancelledLazyStore; private _balanceAndProxyAllowanceLazyStore: BalanceAndProxyAllowanceLazyStore; private _cleanupJobInterval: number; - private _cleanupJobIntervalId: NodeJS.Timer; + private _cleanupJobIntervalIdIfExists?: NodeJS.Timer; constructor( web3Wrapper: Web3Wrapper, abiDecoder: AbiDecoder, token: TokenWrapper, exchange: ExchangeWrapper, config?: OrderStateWatcherConfig, @@ -146,7 +146,7 @@ export class OrderStateWatcher { this._callbackIfExists = callback; this._eventWatcher.subscribe(this._onEventWatcherCallbackAsync.bind(this)); this._expirationWatcher.subscribe(this._onOrderExpired.bind(this)); - this._cleanupJobIntervalId = intervalUtils.setAsyncExcludingInterval( + this._cleanupJobIntervalIdIfExists = intervalUtils.setAsyncExcludingInterval( this._cleanupAsync.bind(this), this._cleanupJobInterval, ); } @@ -154,7 +154,7 @@ export class OrderStateWatcher { * Ends an orderStateWatcher subscription. */ public unsubscribe(): void { - if (_.isUndefined(this._callbackIfExists)) { + if (_.isUndefined(this._callbackIfExists) || _.isUndefined(this._cleanupJobIntervalIdIfExists)) { throw new Error(ZeroExError.SubscriptionNotFound); } this._balanceAndProxyAllowanceLazyStore.deleteAll(); @@ -162,7 +162,7 @@ export class OrderStateWatcher { delete this._callbackIfExists; this._eventWatcher.unsubscribe(); this._expirationWatcher.unsubscribe(); - intervalUtils.clearAsyncExcludingInterval(this._cleanupJobIntervalId); + intervalUtils.clearAsyncExcludingInterval(this._cleanupJobIntervalIdIfExists); } private async _cleanupAsync(): Promise<void> { for (const orderHash of _.keys(this._orderByOrderHash)) { |