UNPKG

ih-black-lion

Version:

State handler for Arus projects

23 lines (19 loc) 820 B
import { delay } from 'redux-saga'; import { takeEvery, takeLatest, put, call } from 'redux-saga/effects'; import { REQUEST_CHECKLIST, RECEIVE_CHECKLIST, SEARCH_CHECKLIST } from '../actionTypes'; export function* fetchChecklist(action) { try { const response = yield call(action.Api.getChecklist, action.requestParms, action.model); yield put({ type: RECEIVE_CHECKLIST, response, status: 'success' }); } catch (error) { yield put({ type: RECEIVE_CHECKLIST, response: error, status: 'error' }); } } export function* searchChecklist(action) { yield call(delay, 500); yield put({ type: SEARCH_CHECKLIST, searchString: action.requestParms }); } export default function* ChecklistSaga() { yield takeEvery(REQUEST_CHECKLIST, fetchChecklist); yield takeLatest(SEARCH_CHECKLIST, searchChecklist); }