All files / sagas ChecklistSaga.js

0% Statements 0/40
0% Branches 0/14
0% Functions 0/6
0% Lines 0/6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23                                             
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);
}