aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-06-27 03:33:38 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-06-27 03:33:38 +0800
commit0a0da63ac7913f0c3a27147a700c9a3dbccf0c40 (patch)
tree30f0a16ea2dbb468c09d496a5c875bbac7a3ba77 /packages/website/ts
parent3866154b505c40008b57afb8b75575eb14419578 (diff)
downloaddexon-sol-tools-0a0da63ac7913f0c3a27147a700c9a3dbccf0c40.tar
dexon-sol-tools-0a0da63ac7913f0c3a27147a700c9a3dbccf0c40.tar.gz
dexon-sol-tools-0a0da63ac7913f0c3a27147a700c9a3dbccf0c40.tar.bz2
dexon-sol-tools-0a0da63ac7913f0c3a27147a700c9a3dbccf0c40.tar.lz
dexon-sol-tools-0a0da63ac7913f0c3a27147a700c9a3dbccf0c40.tar.xz
dexon-sol-tools-0a0da63ac7913f0c3a27147a700c9a3dbccf0c40.tar.zst
dexon-sol-tools-0a0da63ac7913f0c3a27147a700c9a3dbccf0c40.zip
Make unsubscribing work
Diffstat (limited to 'packages/website/ts')
-rw-r--r--packages/website/ts/blockchain.ts6
1 files changed, 5 insertions, 1 deletions
diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts
index 0d8cbdcd4..7bd6fe800 100644
--- a/packages/website/ts/blockchain.ts
+++ b/packages/website/ts/blockchain.ts
@@ -82,6 +82,7 @@ export class Blockchain {
private _web3Wrapper?: Web3Wrapper;
private _blockchainWatcher?: BlockchainWatcher;
private _injectedProviderObservable?: InjectedProviderObservable;
+ private _injectedProviderUpdateHandler: (update: InjectedProviderUpdate) => Promise<void>;
private _userAddressIfExists: string;
private _ledgerSubprovider: LedgerSubprovider;
private _defaultGasPrice: BigNumber;
@@ -186,6 +187,8 @@ export class Blockchain {
this._dispatcher = dispatcher;
const defaultGasPrice = GWEI_IN_WEI * 30;
this._defaultGasPrice = new BigNumber(defaultGasPrice);
+ // We need a unique reference to this function so we can use it to unsubcribe.
+ this._injectedProviderUpdateHandler = this._handleInjectedProviderUpdateAsync.bind(this);
// tslint:disable-next-line:no-floating-promises
this._updateDefaultGasPriceAsync();
// tslint:disable-next-line:no-floating-promises
@@ -521,6 +524,7 @@ export class Blockchain {
}
public destroy(): void {
this._blockchainWatcher.destroy();
+ this._injectedProviderObservable.unsubscribe(this._injectedProviderUpdateHandler);
this._stopWatchingExchangeLogFillEvents();
}
public async fetchTokenInformationAsync(): Promise<void> {
@@ -776,7 +780,7 @@ export class Blockchain {
const injectedProviderObservable = injectedWeb3.currentProvider.publicConfigStore;
if (injectedProviderObservable && !this._injectedProviderObservable) {
this._injectedProviderObservable = injectedProviderObservable;
- this._injectedProviderObservable.subscribe(this._handleInjectedProviderUpdateAsync.bind(this));
+ this._injectedProviderObservable.subscribe(this._injectedProviderUpdateHandler);
}
}
this._updateProviderName(injectedWeb3);