aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/components
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-11-09 06:57:39 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-11-09 06:57:39 +0800
commit7acaae37a969339d1b4971f80d7fd842266bb60b (patch)
tree08925eec8cc75c525d4a384383383cc07d75f77c /packages/instant/src/components
parentc84e163edb329b478749cad09f222cc12e3698fe (diff)
downloaddexon-sol-tools-7acaae37a969339d1b4971f80d7fd842266bb60b.tar
dexon-sol-tools-7acaae37a969339d1b4971f80d7fd842266bb60b.tar.gz
dexon-sol-tools-7acaae37a969339d1b4971f80d7fd842266bb60b.tar.bz2
dexon-sol-tools-7acaae37a969339d1b4971f80d7fd842266bb60b.tar.lz
dexon-sol-tools-7acaae37a969339d1b4971f80d7fd842266bb60b.tar.xz
dexon-sol-tools-7acaae37a969339d1b4971f80d7fd842266bb60b.tar.zst
dexon-sol-tools-7acaae37a969339d1b4971f80d7fd842266bb60b.zip
feat(instant): Heartbeat for updating account info
Diffstat (limited to 'packages/instant/src/components')
-rw-r--r--packages/instant/src/components/zero_ex_instant_provider.tsx13
1 files changed, 12 insertions, 1 deletions
diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx
index fa0588b71..02f14c5b6 100644
--- a/packages/instant/src/components/zero_ex_instant_provider.tsx
+++ b/packages/instant/src/components/zero_ex_instant_provider.tsx
@@ -5,6 +5,7 @@ import * as _ from 'lodash';
import * as React from 'react';
import { Provider as ReduxProvider } from 'react-redux';
+import { ACCOUNT_UPDATE_INTERVAL_TIME_MS } from '../constants';
import { SelectedAssetThemeProvider } from '../containers/selected_asset_theme_provider';
import { asyncData } from '../redux/async_data';
import { DEFAULT_STATE, DefaultState, State } from '../redux/reducer';
@@ -14,6 +15,7 @@ import { AffiliateInfo, AssetMetaData, Network, OrderSource } from '../types';
import { assetUtils } from '../util/asset';
import { errorFlasher } from '../util/error_flasher';
import { gasPriceEstimator } from '../util/gas_price_estimator';
+import { AccountUpdateHeartbeat } from '../util/hearbeats';
import { providerStateFactory } from '../util/provider_state_factory';
fonts.include();
@@ -37,6 +39,7 @@ export interface ZeroExInstantProviderOptionalProps {
export class ZeroExInstantProvider extends React.Component<ZeroExInstantProviderProps> {
private readonly _store: Store;
+ private _accountUpdateHeartbeat?: AccountUpdateHeartbeat;
// TODO(fragosti): Write tests for this beast once we inject a provider.
private static _mergeDefaultStateWithProps(
props: ZeroExInstantProviderProps,
@@ -93,7 +96,10 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
asyncData.fetchAvailableAssetDatasAndDispatchToStore(this._store);
}
// tslint:disable-next-line:no-floating-promises
- asyncData.fetchAccountInfoAndDispatchToStore(this._store);
+ // asyncData.fetchAccountInfoAndDispatchToStore(this._store);
+ this._accountUpdateHeartbeat = new AccountUpdateHeartbeat();
+ this._accountUpdateHeartbeat.start(this._store, ACCOUNT_UPDATE_INTERVAL_TIME_MS);
+
// warm up the gas price estimator cache just in case we can't
// grab the gas price estimate when submitting the transaction
// tslint:disable-next-line:no-floating-promises
@@ -101,6 +107,11 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
// tslint:disable-next-line:no-floating-promises
this._flashErrorIfWrongNetwork();
}
+ public componentWillUnmount(): void {
+ if (this._accountUpdateHeartbeat) {
+ this._accountUpdateHeartbeat.stop();
+ }
+ }
public render(): React.ReactNode {
return (
<ReduxProvider store={this._store}>