diff options
author | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-11-09 09:09:26 +0800 |
---|---|---|
committer | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-11-09 09:09:26 +0800 |
commit | 1e39d56cf751fd922d6fec86ecc8bc70b20bc6bb (patch) | |
tree | 15d1fd1a472d6875340a0e35cdd1d8259958508d /packages/instant/src/components/zero_ex_instant_provider.tsx | |
parent | e45b6c7e98a33de0e13f4ab7db8b630900dbb960 (diff) | |
download | dexon-0x-contracts-1e39d56cf751fd922d6fec86ecc8bc70b20bc6bb.tar.gz dexon-0x-contracts-1e39d56cf751fd922d6fec86ecc8bc70b20bc6bb.tar.zst dexon-0x-contracts-1e39d56cf751fd922d6fec86ecc8bc70b20bc6bb.zip |
wip: BuyQuote heartbeat
Diffstat (limited to 'packages/instant/src/components/zero_ex_instant_provider.tsx')
-rw-r--r-- | packages/instant/src/components/zero_ex_instant_provider.tsx | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx index 1805a11af..24ae0c4b6 100644 --- a/packages/instant/src/components/zero_ex_instant_provider.tsx +++ b/packages/instant/src/components/zero_ex_instant_provider.tsx @@ -5,7 +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 { ACCOUNT_UPDATE_INTERVAL_TIME_MS, BUY_QUOTE_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'; @@ -15,7 +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 { generateAccountHeartbeater, Heartbeater } from '../util/hearbeats'; +import { generateAccountHeartbeater, Heartbeater, generateBuyQuoteHeartbeater } from '../util/hearbeats'; import { providerStateFactory } from '../util/provider_state_factory'; fonts.include(); @@ -40,6 +40,8 @@ export interface ZeroExInstantProviderOptionalProps { export class ZeroExInstantProvider extends React.Component<ZeroExInstantProviderProps> { private readonly _store: Store; private _accountUpdateHeartbeat?: Heartbeater; + private _buyQuoteHeartbeat?: Heartbeater; + // TODO(fragosti): Write tests for this beast once we inject a provider. private static _mergeDefaultStateWithProps( props: ZeroExInstantProviderProps, @@ -101,6 +103,10 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider this._accountUpdateHeartbeat = generateAccountHeartbeater(this._store); this._accountUpdateHeartbeat.start(ACCOUNT_UPDATE_INTERVAL_TIME_MS); + // TODO assign and stop on unmount + this._buyQuoteHeartbeat = generateBuyQuoteHeartbeater(this._store); + this._buyQuoteHeartbeat.start(BUY_QUOTE_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 @@ -112,6 +118,9 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider if (this._accountUpdateHeartbeat) { this._accountUpdateHeartbeat.stop(); } + if (this._buyQuoteHeartbeat) { + this._buyQuoteHeartbeat.stop(); + } } public render(): React.ReactNode { return ( |