mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-01-11 11:34:26 +00:00
e7f88a6a0a
* Use shapeshift for all swaps. * Replace existing redux-promise-middleware based CCRequest action with saga based action. * Remove module from package.json, store middleware, webpack_config. * fix snapshot * Add return typing * Add test for saga
20 lines
706 B
TypeScript
20 lines
706 B
TypeScript
import { fetchCCRatesSucceeded, fetchCCRatesFailed, FetchCCRatesRequested } from 'actions/rates';
|
|
import { SagaIterator } from 'redux-saga';
|
|
import { call, put, takeLatest } from 'redux-saga/effects';
|
|
import { fetchRates, CCResponse } from 'api/rates';
|
|
import { TypeKeys } from 'actions/rates/constants';
|
|
|
|
export function* fetchRatesSaga(action: FetchCCRatesRequested): SagaIterator {
|
|
try {
|
|
const rates: CCResponse = yield call(fetchRates, action.payload);
|
|
yield put(fetchCCRatesSucceeded(rates));
|
|
} catch (e) {
|
|
yield put(fetchCCRatesFailed());
|
|
return;
|
|
}
|
|
}
|
|
|
|
export default function* ratesSaga(): SagaIterator {
|
|
yield takeLatest(TypeKeys.RATES_FETCH_CC_REQUESTED, fetchRatesSaga);
|
|
}
|