Linting and renaming variables

This commit is contained in:
Steve Klebanoff
2018-11-09 11:39:36 -08:00
parent 36b8c9c5dd
commit cc8debe53b
5 changed files with 23 additions and 21 deletions

View File

@@ -98,17 +98,20 @@ export class ZeroExInstantProvider extends React.Component<ZeroExInstantProvider
// tslint:disable-next-line:no-floating-promises
asyncData.fetchAvailableAssetDatasAndDispatchToStore(this._store);
}
// tslint:disable-next-line:no-floating-promises
this._accountUpdateHeartbeat = generateAccountHeartbeater({
store: this._store,
performImmediatelyOnStart: true,
shouldPerformImmediatelyOnStart: true,
});
this._accountUpdateHeartbeat.start(ACCOUNT_UPDATE_INTERVAL_TIME_MS);
this._buyQuoteHeartbeat = generateBuyQuoteHeartbeater({ store: this._store, performImmediatelyOnStart: false });
this._buyQuoteHeartbeat = generateBuyQuoteHeartbeater({
store: this._store,
shouldPerformImmediatelyOnStart: false,
});
this._buyQuoteHeartbeat.start(BUY_QUOTE_UPDATE_INTERVAL_TIME_MS);
asyncData.fetchCurrentBuyQuoteAndDispatchToStore({ store: this._store, setPending: true });
// tslint:disable-next-line:no-floating-promises
asyncData.fetchCurrentBuyQuoteAndDispatchToStore({ store: this._store, shouldSetPending: true });
// warm up the gas price estimator cache just in case we can't
// grab the gas price estimate when submitting the transaction

View File

@@ -36,11 +36,11 @@ export const asyncData = {
store.dispatch(actions.setAvailableAssets([]));
}
},
fetchAccountInfoAndDispatchToStore: async (options: { store: Store; setLoading: boolean }) => {
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,
);
}

View File

@@ -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';

View File

@@ -4,8 +4,8 @@ type HeartbeatableFunction = () => Promise<void>;
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();
}

View File

@@ -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);
};