From 27519e1dfa882d6b8b8a3febf3bea88be845e48f Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 9 Nov 2017 22:57:38 -0500 Subject: rename intervalId to intervalIdIfExists --- src/order_watcher/event_watcher.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/order_watcher/event_watcher.ts b/src/order_watcher/event_watcher.ts index f71b14afb..4cb741617 100644 --- a/src/order_watcher/event_watcher.ts +++ b/src/order_watcher/event_watcher.ts @@ -10,7 +10,7 @@ const DEFAULT_EVENT_POLLING_INTERVAL = 200; export class EventWatcher { private _web3Wrapper: Web3Wrapper; private _pollingIntervalMs: number; - private _intervalId: NodeJS.Timer; + private _intervalIdIfExists?: NodeJS.Timer; private _lastEvents: Web3.LogEntry[] = []; private _callbackIfExistsAsync?: EventWatcherCallback; private _numConfirmations: number; @@ -23,14 +23,16 @@ export class EventWatcher { } public subscribe(callback: EventWatcherCallback): void { this._callbackIfExistsAsync = callback; - this._intervalId = intervalUtils.setAsyncExcludingInterval( + this._intervalIdIfExists = intervalUtils.setAsyncExcludingInterval( this._pollForMempoolEventsAsync.bind(this), this._pollingIntervalMs, ); } public unsubscribe(): void { delete this._callbackIfExistsAsync; this._lastEvents = []; - intervalUtils.clearAsyncExcludingInterval(this._intervalId); + if (!_.isUndefined(this._intervalIdIfExists)) { + intervalUtils.clearAsyncExcludingInterval(this._intervalIdIfExists); + } } private async _pollForMempoolEventsAsync(): Promise { const pendingEvents = await this._getEventsAsync(); -- cgit v1.2.3