All files / sagas NavigationCollectionSaga.js

37.5% Statements 3/8
100% Branches 0/0
33.33% Functions 1/3
37.5% Lines 3/8
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          1x 1x         1x                              
import { delay } from 'redux-saga';
import { takeEvery, takeLatest, put, call } from 'redux-saga/effects';
import { RECEIVE_NAVCOL, REQUEST_NAVCOL, SEARCH_NAVCOL } from '../actionTypes';
 
export function* fetchNavCol(action) {
  try {
    const navCollection = yield call(
      action.Api.getNavigationCollection,
      action.requestParams,
      action.pageletName,
    );
    yield put({ type: RECEIVE_NAVCOL, pageletName: action.pageletName, response: navCollection, status: 'success' });
  } catch (error) {
    yield put({ type: RECEIVE_NAVCOL, pageletName: action.pageletName, response: error, status: 'error' });
  }
}
 
export function* searchNavCol(action) {
  yield call(delay, 500);
  yield put({ type: SEARCH_NAVCOL, searchString: action.searchString, maxResults: action.maxResults });
}
 
export default function* NavCollectionSaga() {
  yield takeEvery(REQUEST_NAVCOL, fetchNavCol);
  yield takeLatest('INPUT_CHANGED', searchNavCol);
}