From 474db7c18de63429f72511796291ff135c77f10b Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Fri, 9 Nov 2018 11:22:46 -0800 Subject: Emulate named parameters with interface --- packages/instant/src/components/zero_ex_instant_provider.tsx | 9 ++++++--- packages/instant/src/redux/async_data.ts | 3 ++- packages/instant/src/util/heartbeater_factory.ts | 12 +++++++++--- 3 files changed, 17 insertions(+), 7 deletions(-) (limited to 'packages/instant/src') diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx index f5605a187..20d677dc2 100644 --- a/packages/instant/src/components/zero_ex_instant_provider.tsx +++ b/packages/instant/src/components/zero_ex_instant_provider.tsx @@ -100,12 +100,15 @@ export class ZeroExInstantProvider extends React.Component { + fetchCurrentBuyQuoteAndDispatchToStore: async (options: { store: Store; setPending: boolean }) => { + const { store, setPending } = options; const { buyOrderState, providerState, selectedAsset, selectedAssetAmount, affiliateInfo } = store.getState(); const assetBuyer = providerState.assetBuyer; if ( diff --git a/packages/instant/src/util/heartbeater_factory.ts b/packages/instant/src/util/heartbeater_factory.ts index beedb66c8..0feb05422 100644 --- a/packages/instant/src/util/heartbeater_factory.ts +++ b/packages/instant/src/util/heartbeater_factory.ts @@ -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); }; -- cgit