From cc8debe53b9a6efc75b91f1b6c47f0820c3beb8c Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Fri, 9 Nov 2018 11:39:36 -0800 Subject: Linting and renaming variables --- .../instant/src/components/zero_ex_instant_provider.tsx | 11 +++++++---- packages/instant/src/redux/async_data.ts | 12 ++++++------ packages/instant/src/util/buy_quote_updater.ts | 2 -- packages/instant/src/util/heartbeater.ts | 5 +++-- packages/instant/src/util/heartbeater_factory.ts | 14 +++++++------- 5 files changed, 23 insertions(+), 21 deletions(-) diff --git a/packages/instant/src/components/zero_ex_instant_provider.tsx b/packages/instant/src/components/zero_ex_instant_provider.tsx index 20d677dc2..1223b477e 100644 --- a/packages/instant/src/components/zero_ex_instant_provider.tsx +++ b/packages/instant/src/components/zero_ex_instant_provider.tsx @@ -98,17 +98,20 @@ export class ZeroExInstantProvider extends React.Component { - const { store, setLoading } = options; + fetchAccountInfoAndDispatchToStore: async (options: { store: Store; shouldSetToLoading: boolean }) => { + const { store, shouldSetToLoading } = options; const { providerState } = store.getState(); const web3Wrapper = providerState.web3Wrapper; - if (setLoading && providerState.account.state !== AccountState.Loading) { + if (shouldSetToLoading && providerState.account.state !== AccountState.Loading) { store.dispatch(actions.setAccountStateLoading()); } let availableAddresses: string[]; @@ -75,8 +75,8 @@ export const asyncData = { return; } }, - fetchCurrentBuyQuoteAndDispatchToStore: async (options: { store: Store; setPending: boolean }) => { - const { store, setPending } = options; + fetchCurrentBuyQuoteAndDispatchToStore: async (options: { store: Store; shouldSetPending: boolean }) => { + const { store, shouldSetPending } = options; const { buyOrderState, providerState, selectedAsset, selectedAssetAmount, affiliateInfo } = store.getState(); const assetBuyer = providerState.assetBuyer; if ( @@ -90,7 +90,7 @@ export const asyncData = { store.dispatch, selectedAsset as ERC20Asset, selectedAssetAmount, - setPending, + shouldSetPending, affiliateInfo, ); } diff --git a/packages/instant/src/util/buy_quote_updater.ts b/packages/instant/src/util/buy_quote_updater.ts index fb5da311d..c33e28f1c 100644 --- a/packages/instant/src/util/buy_quote_updater.ts +++ b/packages/instant/src/util/buy_quote_updater.ts @@ -1,5 +1,4 @@ import { AssetBuyer, AssetBuyerError, BuyQuote } from '@0x/asset-buyer'; -import { AssetProxyId } from '@0x/types'; import { BigNumber } from '@0x/utils'; import { Web3Wrapper } from '@0x/web3-wrapper'; import * as _ from 'lodash'; @@ -7,7 +6,6 @@ import { Dispatch } from 'redux'; import { oc } from 'ts-optchain'; import { Action, actions } from '../redux/actions'; -import { State } from '../redux/reducer'; import { AffiliateInfo, ERC20Asset } from '../types'; import { assetUtils } from '../util/asset'; import { errorFlasher } from '../util/error_flasher'; diff --git a/packages/instant/src/util/heartbeater.ts b/packages/instant/src/util/heartbeater.ts index 87af48423..a5b42d87f 100644 --- a/packages/instant/src/util/heartbeater.ts +++ b/packages/instant/src/util/heartbeater.ts @@ -4,8 +4,8 @@ type HeartbeatableFunction = () => Promise; export class Heartbeater { private _intervalId?: number; private _hasPendingRequest: boolean; - private _performImmediatelyOnStart: boolean; - private _performFunction: HeartbeatableFunction; + private readonly _performImmediatelyOnStart: boolean; + private readonly _performFunction: HeartbeatableFunction; public constructor(performingFunctionAsync: HeartbeatableFunction, performImmediatelyOnStart: boolean) { this._performFunction = performingFunctionAsync; @@ -19,6 +19,7 @@ export class Heartbeater { } if (this._performImmediatelyOnStart) { + // tslint:disable-next-line:no-floating-promises this._trackAndPerformAsync(); } diff --git a/packages/instant/src/util/heartbeater_factory.ts b/packages/instant/src/util/heartbeater_factory.ts index 805483b71..96a8ac4e6 100644 --- a/packages/instant/src/util/heartbeater_factory.ts +++ b/packages/instant/src/util/heartbeater_factory.ts @@ -5,18 +5,18 @@ import { Heartbeater } from './heartbeater'; export interface HeartbeatFactoryOptions { store: Store; - performImmediatelyOnStart: boolean; + shouldPerformImmediatelyOnStart: boolean; } export const generateAccountHeartbeater = (options: HeartbeatFactoryOptions): Heartbeater => { - const { store, performImmediatelyOnStart } = options; + const { store, shouldPerformImmediatelyOnStart } = options; return new Heartbeater(async () => { - await asyncData.fetchAccountInfoAndDispatchToStore({ store, setLoading: false }); - }, performImmediatelyOnStart); + await asyncData.fetchAccountInfoAndDispatchToStore({ store, shouldSetToLoading: false }); + }, shouldPerformImmediatelyOnStart); }; export const generateBuyQuoteHeartbeater = (options: HeartbeatFactoryOptions): Heartbeater => { - const { store, performImmediatelyOnStart } = options; + const { store, shouldPerformImmediatelyOnStart } = options; return new Heartbeater(async () => { - await asyncData.fetchCurrentBuyQuoteAndDispatchToStore({ store, setPending: false }); - }, performImmediatelyOnStart); + await asyncData.fetchCurrentBuyQuoteAndDispatchToStore({ store, shouldSetPending: false }); + }, shouldPerformImmediatelyOnStart); }; -- cgit