diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-21 06:25:51 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-21 06:25:51 +0800 |
commit | 3bc3666215d4fdaa6d9db87e065ca5e762df9b25 (patch) | |
tree | 2ff00759cecbeef8c754818b4469334d3f3ea620 /packages/0x.js/src/order_watcher/order_state_watcher.ts | |
parent | b01a4af99ed246cda6307ea10303ad25d2cadbe0 (diff) | |
download | dexon-sol-tools-3bc3666215d4fdaa6d9db87e065ca5e762df9b25.tar dexon-sol-tools-3bc3666215d4fdaa6d9db87e065ca5e762df9b25.tar.gz dexon-sol-tools-3bc3666215d4fdaa6d9db87e065ca5e762df9b25.tar.bz2 dexon-sol-tools-3bc3666215d4fdaa6d9db87e065ca5e762df9b25.tar.lz dexon-sol-tools-3bc3666215d4fdaa6d9db87e065ca5e762df9b25.tar.xz dexon-sol-tools-3bc3666215d4fdaa6d9db87e065ca5e762df9b25.tar.zst dexon-sol-tools-3bc3666215d4fdaa6d9db87e065ca5e762df9b25.zip |
Check if callback exists
Diffstat (limited to 'packages/0x.js/src/order_watcher/order_state_watcher.ts')
-rw-r--r-- | packages/0x.js/src/order_watcher/order_state_watcher.ts | 10 |
1 files changed, 6 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 579fa388a..84f2128c0 100644 --- a/packages/0x.js/src/order_watcher/order_state_watcher.ts +++ b/packages/0x.js/src/order_watcher/order_state_watcher.ts @@ -128,7 +128,7 @@ export class OrderStateWatcher { } this._callbackIfExists = callback; this._eventWatcher.subscribe(this._onEventWatcherCallbackAsync.bind(this)); - this._expirationWatcher.subscribe(this._onOrderExpired.bind(this)); + this._expirationWatcher.subscribe(this._onOrderExpiredAsync.bind(this)); } /** * Ends an orderStateWatcher subscription. @@ -143,7 +143,7 @@ export class OrderStateWatcher { this._eventWatcher.unsubscribe(); this._expirationWatcher.unsubscribe(); } - private _onOrderExpired(orderHash: string): void { + private async _onOrderExpiredAsync(orderHash: string): Promise<void> { const orderState: OrderState = { isValid: false, orderHash, @@ -151,8 +151,10 @@ export class OrderStateWatcher { }; if (!_.isUndefined(this._orderByOrderHash[orderHash])) { // We need this check because we never remove the orders from expiration watcher - this.removeOrder(orderHash); - (this._callbackIfExistsAsync as OnOrderStateChangeCallback)(orderState); + await this.removeOrderAsync(orderHash); + if (!_.isUndefined(this._callbackIfExists)) { + this._callbackIfExists(orderState); + } } } private async _onEventWatcherCallbackAsync(log: LogEvent): Promise<void> { |