All files / sagas ServiceIndicatorSaga.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 24 25 26 27                                                     
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);
}