aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/src
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-11-29 04:27:16 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-11-29 04:27:16 +0800
commite4dfdc6b5c9073470ef7f70325d013ec20c7da96 (patch)
tree8f7f20a3b9336249c298057a20d6985427b52191 /packages/0x.js/src
parent9e673f0073b9e6c58256df88bd2d061593a6b1bc (diff)
downloaddexon-0x-contracts-e4dfdc6b5c9073470ef7f70325d013ec20c7da96.tar.gz
dexon-0x-contracts-e4dfdc6b5c9073470ef7f70325d013ec20c7da96.tar.zst
dexon-0x-contracts-e4dfdc6b5c9073470ef7f70325d013ec20c7da96.zip
Add ifExists to cleanupJobInterval
Diffstat (limited to 'packages/0x.js/src')
-rw-r--r--packages/0x.js/src/order_watcher/order_state_watcher.ts8
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)) {