Members
(static, constant) sagas
sagas are asynchronous workers (JS generators) to handle the state.
// Worker
export function * incrementAsync () {
try {
const data = yield call(Api.isIncrementOk)
yield put({ type: 'INCREMENT_SUCCESS', data })
} catch (error) {
yield put({ type: 'INCREMENT_FAIL', error})
}
}
// Watcher (intercepts INCREMENT_REQUEST, dispatches INCREMENT_SUCCESS or INCREMENT_FAIL in return.)
export function * watchIncrementAsync () {
yield takeEvery('INCREMENT_REQUEST', incrementAsync)
}
// export all sagas in parallel
function * sagas () {
yield takeEvery('INCREMENT_REQUEST')
yield takeEvery('DECREMENT_REQUEST')
}
- Source:
(static, constant) state
It is generally easier to not have another object here.
- Source:
(inner, constant) actionTypes
actionTypes define what actions are handeled by the reducer.
- Source:
Methods
(static) reducer()
The module's root reducer tries to split up the state and let specific
specialized reducers handle the work. This is not necessary, but more
convenient and readable.
- Source: