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/expiration_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/expiration_watcher.ts')
-rw-r--r-- | packages/0x.js/src/order_watcher/expiration_watcher.ts | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/packages/0x.js/src/order_watcher/expiration_watcher.ts b/packages/0x.js/src/order_watcher/expiration_watcher.ts index 7d6ce6bdd..efedd3cf8 100644 --- a/packages/0x.js/src/order_watcher/expiration_watcher.ts +++ b/packages/0x.js/src/order_watcher/expiration_watcher.ts @@ -29,12 +29,12 @@ export class ExpirationWatcher { const comparator = (lhs: string, rhs: string) => scoreFunction(lhs) - scoreFunction(rhs); this.orderHashByExpirationRBTree = new RBTree(comparator); } - public subscribe(callback: (orderHash: string) => void): void { + public subscribe(callbackAsync: (orderHash: string) => Promise<void>): void { if (!_.isUndefined(this.orderExpirationCheckingIntervalIdIfExists)) { throw new Error(ZeroExError.SubscriptionAlreadyPresent); } this.orderExpirationCheckingIntervalIdIfExists = intervalUtils.setAsyncExcludingInterval( - this.pruneExpiredOrders.bind(this, callback), this.orderExpirationCheckingIntervalMs, + this.pruneExpiredOrdersAsync.bind(this, callbackAsync), this.orderExpirationCheckingIntervalMs, ); } public unsubscribe(): void { @@ -52,7 +52,7 @@ export class ExpirationWatcher { this.orderHashByExpirationRBTree.remove(orderHash); delete this.expiration[orderHash]; } - private pruneExpiredOrders(callback: (orderHash: string) => void): void { + private async pruneExpiredOrdersAsync(callbackAsync: (orderHash: string) => Promise<void>): Promise<void> { const currentUnixTimestampMs = utils.getCurrentUnixTimestampMs(); while ( this.orderHashByExpirationRBTree.size !== 0 && @@ -63,7 +63,7 @@ export class ExpirationWatcher { const orderHash = this.orderHashByExpirationRBTree.min(); this.orderHashByExpirationRBTree.remove(orderHash); delete this.expiration[orderHash]; - callback(orderHash); + await callbackAsync(orderHash); } } } |