aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-11-11 07:07:11 +0800
committerFabio Berger <me@fabioberger.com>2017-11-11 07:07:11 +0800
commit6012926e8278bed55b173a8e8380231c75a1a48c (patch)
treeca860f802b7645a1ecf6e077cc2706e6c381e67d /src
parentca9c1bca4a694026981a804c58138f08c8b23321 (diff)
downloaddexon-sol-tools-6012926e8278bed55b173a8e8380231c75a1a48c.tar
dexon-sol-tools-6012926e8278bed55b173a8e8380231c75a1a48c.tar.gz
dexon-sol-tools-6012926e8278bed55b173a8e8380231c75a1a48c.tar.bz2
dexon-sol-tools-6012926e8278bed55b173a8e8380231c75a1a48c.tar.lz
dexon-sol-tools-6012926e8278bed55b173a8e8380231c75a1a48c.tar.xz
dexon-sol-tools-6012926e8278bed55b173a8e8380231c75a1a48c.tar.zst
dexon-sol-tools-6012926e8278bed55b173a8e8380231c75a1a48c.zip
Throw if trying to subscribe multiple times
Diffstat (limited to 'src')
-rw-r--r--src/order_watcher/event_watcher.ts10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/order_watcher/event_watcher.ts b/src/order_watcher/event_watcher.ts
index 286872a6f..c11b78f2e 100644
--- a/src/order_watcher/event_watcher.ts
+++ b/src/order_watcher/event_watcher.ts
@@ -1,7 +1,12 @@
import * as Web3 from 'web3';
import * as _ from 'lodash';
import {Web3Wrapper} from '../web3_wrapper';
-import {BlockParamLiteral, EventCallback, EventWatcherCallback} from '../types';
+import {
+ BlockParamLiteral,
+ EventCallback,
+ EventWatcherCallback,
+ ZeroExError,
+} from '../types';
import {AbiDecoder} from '../utils/abi_decoder';
import {intervalUtils} from '../utils/interval_utils';
import {assert} from '../utils/assert';
@@ -28,6 +33,9 @@ export class EventWatcher {
}
public subscribe(callback: EventWatcherCallback): void {
assert.isFunction('callback', callback);
+ if (!_.isUndefined(this._callbackIfExistsAsync)) {
+ throw new Error(ZeroExError.SubscriptionAlreadyPresent);
+ }
this._callbackIfExistsAsync = callback;
this._intervalIdIfExists = intervalUtils.setAsyncExcludingInterval(
this._pollForBlockchainEventsAsync.bind(this), this._pollingIntervalMs,