aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/util/heartbeater_factory.ts
blob: 9fac9cf4c4aabd54a329e2936349264a8643a490 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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);
    });
};