aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-11-10 03:22:46 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-11-10 03:22:46 +0800
commit474db7c18de63429f72511796291ff135c77f10b (patch)
tree63eee7214fafd8d69cb982036906a6c1e651b7d7 /packages/instant
parent39657b633bd386526f5772238cbebfb976427c07 (diff)
downloaddexon-sol-tools-474db7c18de63429f72511796291ff135c77f10b.tar
dexon-sol-tools-474db7c18de63429f72511796291ff135c77f10b.tar.gz
dexon-sol-tools-474db7c18de63429f72511796291ff135c77f10b.tar.bz2
dexon-sol-tools-474db7c18de63429f72511796291ff135c77f10b.tar.lz
dexon-sol-tools-474db7c18de63429f72511796291ff135c77f10b.tar.xz
dexon-sol-tools-474db7c18de63429f72511796291ff135c77f10b.tar.zst
dexon-sol-tools-474db7c18de63429f72511796291ff135c77f10b.zip
Emulate named parameters with interface
Diffstat (limited to 'packages/instant')
-rw-r--r--packages/instant/src/components/zero_ex_instant_provider.tsx9
-rw-r--r--packages/instant/src/redux/async_data.ts3
-rw-r--r--packages/instant/src/util/heartbeater_factory.ts12
3 files changed, 17 insertions, 7 deletions
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<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
diff --git a/packages/instant/src/redux/async_data.ts b/packages/instant/src/redux/async_data.ts
index c7fe4cd0e..61de54d82 100644
--- a/packages/instant/src/redux/async_data.ts
+++ b/packages/instant/src/redux/async_data.ts
@@ -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 (
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);
};