aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/redux/async_data.ts
blob: 3488383074b94fcf7e5e0cb7320f30614fd0e7f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { BIG_NUMBER_ZERO } from '../constants';
import { coinbaseApi } from '../util/coinbase_api';

import { ActionTypes } from './actions';

import { store } from './store';

export const asyncData = {
    fetchAndDispatchToStore: async () => {
        let ethUsdPrice = BIG_NUMBER_ZERO;
        try {
            ethUsdPrice = await coinbaseApi.getEthUsdPrice();
        } catch (e) {
            // ignore
        } finally {
            store.dispatch({
                type: ActionTypes.UPDATE_ETH_USD_PRICE,
                data: ethUsdPrice,
            });
        }
    },
};