blob: 96a8ac4e6e55865adf4724b98d51c98be83dc40a (
plain) (
tree)
|
|
import { asyncData } from '../redux/async_data';
import { Store } from '../redux/store';
import { Heartbeater } from './heartbeater';
export interface HeartbeatFactoryOptions {
store: Store;
shouldPerformImmediatelyOnStart: boolean;
}
export const generateAccountHeartbeater = (options: HeartbeatFactoryOptions): Heartbeater => {
const { store, shouldPerformImmediatelyOnStart } = options;
return new Heartbeater(async () => {
await asyncData.fetchAccountInfoAndDispatchToStore({ store, shouldSetToLoading: false });
}, shouldPerformImmediatelyOnStart);
};
export const generateBuyQuoteHeartbeater = (options: HeartbeatFactoryOptions): Heartbeater => {
const { store, shouldPerformImmediatelyOnStart } = options;
return new Heartbeater(async () => {
await asyncData.fetchCurrentBuyQuoteAndDispatchToStore({ store, shouldSetPending: false });
}, shouldPerformImmediatelyOnStart);
};
|