Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export default function* rootSaga() {
- yield [
- helloSaga(),
- watchIncrementAsync()
- ]
- }
- export default function* rootSaga() {
- yield fork(watchFetchUsers)
- yield fork(watchCreateUser)
- }
- export default function* root() {
- yield [
- fork(getAllProducts),
- fork(watchGetProducts),
- fork(watchCheckout)
- ]
- }
- const makeRestartable = (saga) => {
- return function* () {
- yield spawn(function* () {
- while (true) {
- try {
- yield call(saga);
- console.error("unexpected root saga termination. The root sagas are supposed to be sagas that live during the whole app lifetime!",saga);
- } catch (e) {
- console.error("Saga error, the saga will be restarted",e);
- }
- yield delay(1000); // Workaround to avoid infinite error loops
- }
- })
- };
- };
- const rootSagas = [
- domain1saga,
- domain2saga,
- domain3saga,
- ].map(makeRestartable);
- export default function* root() {
- yield rootSagas.map(saga => call(saga));
- }
- import { fork, all } from 'redux-saga/effects';
- import firstSaga from './firstSaga';
- import secondSaga from './secondSaga';
- import thirdSaga from './thirdSaga';
- export default function* rootSaga() {
- yield all([
- fork(firstSaga),
- fork(secondSaga),
- fork(thirdSaga),
- ]);
- }
- // foo.js
- import { takeEvery } from 'redux-saga/effects';
- export const fooSagas = [
- takeEvery("FOO_A", fooASaga),
- takeEvery("FOO_B", fooBSaga),
- ]
- // bar.js
- import { takeEvery } from 'redux-saga/effects';
- export const barSagas = [
- takeEvery("BAR_A", barASaga),
- takeEvery("BAR_B", barBSaga),
- ];
- // index.js
- import { fooSagas } from './foo';
- import { barSagas } from './bar';
- export default function* rootSaga() {
- yield all([
- ...fooSagas,
- ...barSagas
- ])
- }
Add Comment
Please, Sign In to add comment