diff options
Diffstat (limited to 'packages/instant/src/util/hearbeats.ts')
-rw-r--r-- | packages/instant/src/util/hearbeats.ts | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/packages/instant/src/util/hearbeats.ts b/packages/instant/src/util/hearbeats.ts index 443fd13ec..ecd7c5068 100644 --- a/packages/instant/src/util/hearbeats.ts +++ b/packages/instant/src/util/hearbeats.ts @@ -1,9 +1,14 @@ // TODO: rename file import * as _ from 'lodash'; +import { Dispatch } from 'redux'; -import { asyncData } from './../redux/async_data'; -import { Store } from './../redux/store'; +import { Action } from '../redux/actions'; +import { asyncData } from '../redux/async_data'; +import { State } from '../redux/reducer'; +import { Store } from '../redux/store'; + +import { updateBuyQuoteOrFlashErrorAsyncForState } from './buy_quote_fetcher'; type HeartbeatableFunction = () => Promise<void>; export class Heartbeater { @@ -39,7 +44,7 @@ export class Heartbeater { this._pendingRequest = true; try { - this._performingFunctionAsync(); + await this._performingFunctionAsync(); } finally { this._pendingRequest = false; } @@ -51,3 +56,10 @@ export const generateAccountHeartbeater = (store: Store): Heartbeater => { await asyncData.fetchAccountInfoAndDispatchToStore(store, { setLoading: false }); }); }; + +export const generateBuyQuoteHeartbeater = (store: Store): Heartbeater => { + return new Heartbeater(async () => { + await updateBuyQuoteOrFlashErrorAsyncForState(store.getState(), store.dispatch); + return Promise.resolve(); + }); +}; |