From b0491b0ee28e6d9fd7e3a5647284c99bd79d4930 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 9 Nov 2017 17:48:05 -0500 Subject: Rename _callbackAsync to _callbackIfExistsAsync for clarity --- src/order_watcher/event_watcher.ts | 10 +++++----- src/order_watcher/order_state_watcher.ts | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/order_watcher') diff --git a/src/order_watcher/event_watcher.ts b/src/order_watcher/event_watcher.ts index f1a2b5729..ce471b58d 100644 --- a/src/order_watcher/event_watcher.ts +++ b/src/order_watcher/event_watcher.ts @@ -12,7 +12,7 @@ export class EventWatcher { private _pollingIntervalMs: number; private _intervalId: NodeJS.Timer; private _lastEvents: Web3.LogEntry[] = []; - private _callbackAsync?: EventWatcherCallback; + private _callbackIfExistsAsync?: EventWatcherCallback; constructor(web3Wrapper: Web3Wrapper, pollingIntervalMs: undefined|number) { this._web3Wrapper = web3Wrapper; this._pollingIntervalMs = _.isUndefined(pollingIntervalMs) ? @@ -20,13 +20,13 @@ export class EventWatcher { pollingIntervalMs; } public subscribe(callback: EventWatcherCallback, numConfirmations: number): void { - this._callbackAsync = callback; + this._callbackIfExistsAsync = callback; this._intervalId = intervalUtils.setAsyncExcludingInterval( this._pollForMempoolEventsAsync.bind(this, numConfirmations), this._pollingIntervalMs, ); } public unsubscribe(): void { - delete this._callbackAsync; + delete this._callbackIfExistsAsync; this._lastEvents = []; intervalUtils.clearAsyncExcludingInterval(this._intervalId); } @@ -70,8 +70,8 @@ export class EventWatcher { removed: isRemoved, ...log, }; - if (!_.isUndefined(this._callbackAsync)) { - await this._callbackAsync(logEvent); + if (!_.isUndefined(this._callbackIfExistsAsync)) { + await this._callbackIfExistsAsync(logEvent); } } } diff --git a/src/order_watcher/order_state_watcher.ts b/src/order_watcher/order_state_watcher.ts index 88f6aae69..1c5898c28 100644 --- a/src/order_watcher/order_state_watcher.ts +++ b/src/order_watcher/order_state_watcher.ts @@ -36,7 +36,7 @@ export class OrderStateWatcher { private _orders: OrderByOrderHash; private _dependentOrderHashes: DependentOrderHashes; private _web3Wrapper: Web3Wrapper; - private _callbackAsync?: OnOrderStateChangeCallback; + private _callbackIfExistsAsync?: OnOrderStateChangeCallback; private _eventWatcher: EventWatcher; private _abiDecoder: AbiDecoder; private _orderStateUtils: OrderStateUtils; @@ -89,10 +89,10 @@ export class OrderStateWatcher { */ public subscribe(callback: OnOrderStateChangeCallback, numConfirmations: number): void { assert.isFunction('callback', callback); - if (!_.isUndefined(this._callbackAsync)) { + if (!_.isUndefined(this._callbackIfExistsAsync)) { throw new Error(ZeroExError.SubscriptionAlreadyPresent); } - this._callbackAsync = callback; + this._callbackIfExistsAsync = callback; this._eventWatcher.subscribe(this._onEventWatcherCallbackAsync.bind(this), numConfirmations); } /** @@ -100,7 +100,7 @@ export class OrderStateWatcher { * @param signedOrder The order you wish to stop watching. */ public unsubscribe(): void { - delete this._callbackAsync; + delete this._callbackIfExistsAsync; this._eventWatcher.unsubscribe(); } private async _onEventWatcherCallbackAsync(log: LogEvent): Promise { @@ -158,8 +158,8 @@ export class OrderStateWatcher { for (const orderHash of orderHashes) { const signedOrder = this._orders[orderHash] as SignedOrder; const orderState = await this._orderStateUtils.getOrderStateAsync(signedOrder, methodOpts); - if (!_.isUndefined(this._callbackAsync)) { - await this._callbackAsync(orderState); + if (!_.isUndefined(this._callbackIfExistsAsync)) { + await this._callbackIfExistsAsync(orderState); } else { break; // Unsubscribe was called } -- cgit