我有两个sagas,并试图合并到我的根传奇中。但是,这不符合我的预期。
这是传奇数字1
import { put, takeEvery, all } from 'redux-saga/effects';
// Categories
function* requestAddCategory({ name }) {
try {
.....
});
} catch (err) {
}
}
export function* watcherSaga() {
yield takeEvery(type.REQUEST_ADD_CATEGORY, requestAddCategory);
}
export default function* organize() {
yield all([watcherSaga()]);
}
和传奇数字2
import { put, takeEvery, all } from 'redux-saga/effects';
//Login Auth
function* userLogin({ payload }) {
try {
});
},
});
} catch (err) {
}
}
export function* watcherSaga() {
yield takeEvery(type.USER_LOGIN, userLogin);
}
export default function* userAuthSaga() {
yield all([watcherSaga()]);
}
我将这两个圣人结合在一起
import { all, fork } from 'redux-saga/effects';
import userAuthSaga from './webServiceSagas/user/userAuth';
import organize from './organize/organize';
export default function* rootSaga() {
yield all([fork(userAuthSaga)], fork(organize));
}
它已连接到
import { createStore, applyMiddleware, compose } from 'redux';
import createSagaMiddleware from 'redux-saga';
import rootReducer from './reducers';
import rootSaga from './sagas';
const sagaMiddleware = createSagaMiddleware();
export const store = createStore(
rootReducer,
compose(applyMiddleware(sagaMiddleware))
);
sagaMiddleware.run(rootSaga);
我在这里想念什么吗?在我开始组织它并尝试使用redux-saga网页方法之前,它已经奏效。但是,我不太了解如何处理watcherSaga()。
答案 0 :(得分:1)
根据docs,您可以通过以下方式将sagas组合成根传奇:
const [task1, task2, task3] = yield all([ fork(saga1), fork(saga2), fork(saga3) ])