Emulate named parameters with interface
This commit is contained in:
@@ -100,12 +100,15 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
|
||||
}
|
||||
// tslint:disable-next-line:no-floating-promises
|
||||
|
||||
this._accountUpdateHeartbeat = generateAccountHeartbeater(this._store, true);
|
||||
this._accountUpdateHeartbeat = generateAccountHeartbeater({
|
||||
store: this._store,
|
||||
performImmediatelyOnStart: true,
|
||||
});
|
||||
this._accountUpdateHeartbeat.start(ACCOUNT_UPDATE_INTERVAL_TIME_MS);
|
||||
|
||||
this._buyQuoteHeartbeat = generateBuyQuoteHeartbeater(this._store, false);
|
||||
this._buyQuoteHeartbeat = generateBuyQuoteHeartbeater({ store: this._store, performImmediatelyOnStart: false });
|
||||
this._buyQuoteHeartbeat.start(BUY_QUOTE_UPDATE_INTERVAL_TIME_MS);
|
||||
asyncData.fetchCurrentBuyQuoteAndDispatchToStore(this._store, true);
|
||||
asyncData.fetchCurrentBuyQuoteAndDispatchToStore({ store: this._store, setPending: true });
|
||||
|
||||
// warm up the gas price estimator cache just in case we can't
|
||||
// grab the gas price estimate when submitting the transaction
|
||||
|
||||
@@ -74,7 +74,8 @@ export const asyncData = {
|
||||
return;
|
||||
}
|
||||
},
|
||||
fetchCurrentBuyQuoteAndDispatchToStore: async (store: Store, setPending: boolean) => {
|
||||
fetchCurrentBuyQuoteAndDispatchToStore: async (options: { store: Store; setPending: boolean }) => {
|
||||
const { store, setPending } = options;
|
||||
const { buyOrderState, providerState, selectedAsset, selectedAssetAmount, affiliateInfo } = store.getState();
|
||||
const assetBuyer = providerState.assetBuyer;
|
||||
if (
|
||||
|
||||
@@ -3,14 +3,20 @@ import { Store } from '../redux/store';
|
||||
|
||||
import { Heartbeater } from './heartbeater';
|
||||
|
||||
export const generateAccountHeartbeater = (store: Store, performImmediatelyOnStart: boolean): Heartbeater => {
|
||||
export interface HeartbeatFactoryOptions {
|
||||
store: Store;
|
||||
performImmediatelyOnStart: boolean;
|
||||
}
|
||||
export const generateAccountHeartbeater = (options: HeartbeatFactoryOptions): Heartbeater => {
|
||||
const { store, performImmediatelyOnStart } = options;
|
||||
return new Heartbeater(async () => {
|
||||
await asyncData.fetchAccountInfoAndDispatchToStore(store, { setLoading: false });
|
||||
}, performImmediatelyOnStart);
|
||||
};
|
||||
|
||||
export const generateBuyQuoteHeartbeater = (store: Store, performImmediatelyOnStart: boolean): Heartbeater => {
|
||||
export const generateBuyQuoteHeartbeater = (options: HeartbeatFactoryOptions): Heartbeater => {
|
||||
const { store, performImmediatelyOnStart } = options;
|
||||
return new Heartbeater(async () => {
|
||||
await asyncData.fetchCurrentBuyQuoteAndDispatchToStore(store, false);
|
||||
await asyncData.fetchCurrentBuyQuoteAndDispatchToStore({ store, setPending: false });
|
||||
}, performImmediatelyOnStart);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user