aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-11-10 11:57:38 +0800
committerFabio Berger <me@fabioberger.com>2017-11-10 11:57:38 +0800
commit27519e1dfa882d6b8b8a3febf3bea88be845e48f (patch)
tree3d20ec4e52fbe640ff0ebb5b9fb2cafaa3decbe8 /src
parentdbbcbed34461f81ab62f46e811a7ec741739d3bf (diff)
downloaddexon-sol-tools-27519e1dfa882d6b8b8a3febf3bea88be845e48f.tar
dexon-sol-tools-27519e1dfa882d6b8b8a3febf3bea88be845e48f.tar.gz
dexon-sol-tools-27519e1dfa882d6b8b8a3febf3bea88be845e48f.tar.bz2
dexon-sol-tools-27519e1dfa882d6b8b8a3febf3bea88be845e48f.tar.lz
dexon-sol-tools-27519e1dfa882d6b8b8a3febf3bea88be845e48f.tar.xz
dexon-sol-tools-27519e1dfa882d6b8b8a3febf3bea88be845e48f.tar.zst
dexon-sol-tools-27519e1dfa882d6b8b8a3febf3bea88be845e48f.zip
rename intervalId to intervalIdIfExists
Diffstat (limited to 'src')
-rw-r--r--src/order_watcher/event_watcher.ts8
1 files 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<void> {
const pendingEvents = await this._getEventsAsync();