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

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

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