UNPKG

ih-black-lion

Version:

State handler for Arus projects

27 lines (23 loc) 950 B
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); }