提交 d2d866ae authored 作者: vipcxj's avatar vipcxj

fix: saga effect不需要额外加命名空间前缀,dva已经处理过了

上级 3f6e00e1
...@@ -42,14 +42,14 @@ const hackDispatch = (module, dispatch) => action => dispatch({ ...@@ -42,14 +42,14 @@ const hackDispatch = (module, dispatch) => action => dispatch({
}); });
const hackSagaEffects = (module, sagaEffects) => { const hackSagaEffects = (module, sagaEffects) => {
const put = (action) => { // const put = (action) => {
const { type } = action; // const { type } = action;
return sagaEffects.put({ ...action, type: `${module}/${type}` }); // return sagaEffects.put({ ...action, type: `${module}/${type}` });
}; // };
put.resolve = (action) => { // put.resolve = (action) => {
const { type } = action; // const { type } = action;
return sagaEffects.put.resolve({ ...action, type: `${module}/${type}` }); // return sagaEffects.put.resolve({ ...action, type: `${module}/${type}` });
}; // };
const select = (selector, ...args) => { const select = (selector, ...args) => {
const _selector = (state, ..._args) => { const _selector = (state, ..._args) => {
const keys = Object.keys(state); const keys = Object.keys(state);
...@@ -64,22 +64,22 @@ const hackSagaEffects = (module, sagaEffects) => { ...@@ -64,22 +64,22 @@ const hackSagaEffects = (module, sagaEffects) => {
}; };
return sagaEffects.select(_selector, ...args); return sagaEffects.select(_selector, ...args);
}; };
const take = (type) => { // const take = (type) => {
const { take: oTake } = sagaEffects; // const { take: oTake } = sagaEffects;
if (typeof type === 'string') { // if (typeof type === 'string') {
return oTake(`${module}/${type}`); // return oTake(`${module}/${type}`);
} else if (Array.isArray(type)) { // } else if (Array.isArray(type)) {
return oTake(type.map((t) => { // return oTake(type.map((t) => {
if (typeof t === 'string') { // if (typeof t === 'string') {
return `${module}/${type}`; // return `${module}/${type}`;
} // }
return t; // return t;
})); // }));
} else { // } else {
return oTake(type); // return oTake(type);
} // }
}; // };
return { ...sagaEffects, put, take, select }; return { ...sagaEffects, select };
}; };
const hackEffect = (module, effect) => function * effectGenerator(action, sagaEffects) { const hackEffect = (module, effect) => function * effectGenerator(action, sagaEffects) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论