UNPKG

ih-black-lion

Version:

State handler for Arus projects

27 lines (23 loc) 934 B
import { delay } from 'redux-saga'; import { takeEvery, takeLatest, put, call } from 'redux-saga/effects'; import { REQUEST_SERVICE_INDICATORS, RECEIVE_SERVICE_INDICATORS, SEARCH_SERVICE_INDICATORS, } from '../actionTypes'; export function* fetchServiceIndicators(action) { try { const response = yield call(action.Api.getServiceIndicators, action.requestParams); yield put({ type: RECEIVE_SERVICE_INDICATORS, response, status: 'success' }); } catch (error) { yield put({ type: RECEIVE_SERVICE_INDICATORS, response: error, status: 'error' }); } } export function* searchServiceIndicators(action) { yield call(delay, 500); yield put({ type: SEARCH_SERVICE_INDICATORS, searchString: action.requestParams }); } export default function* ServiceIndicatorSaga() { yield takeEvery(REQUEST_SERVICE_INDICATORS, fetchServiceIndicators); yield takeLatest(SEARCH_SERVICE_INDICATORS, searchServiceIndicators); }