aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/util/heartbeater_factory.ts
blob: fc33787ee13b954488a602968d16fe05c6ea8423 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { asyncData } from '../redux/async_data';
import { Store } from '../redux/store';

import { updateBuyQuoteOrFlashErrorAsyncForState } from './buy_quote_fetcher';
import { Heartbeater } from './heartbeater';

export const generateAccountHeartbeater = (store: Store): Heartbeater => {
    return new Heartbeater(async () => {
        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();
    });
};