【发布时间】:2023-03-14 23:55:01
【问题描述】:
所以,我想将一些函数setupSocket 作为参数推送到嵌套生成器createSaga 中执行,但现在我不明白我该怎么做?
在父生成器mySaga内部setupSocket正常显示,但在createSaga内部不行...
import { takeEvery, put, call, take } from 'redux-saga/effects';
import { delay } from 'redux-saga';
import { addMessage, addUser } from '../actions'
import * as constants from '../constants'
function* createSaga(action, setupSocket) {
try {
console.log(setupSocket); // not good
yield put(addMessage(action.message, action.author, action.photo));
yield put(addUser(action.author, action.photo));
} catch (e) {
console.log(e)
}
};
function* mySaga(setupSocket) {
console.log(setupSocket); // all good
yield takeEvery(constants.ADD_DATA, createSaga);
};
export default mySaga;
【问题讨论】:
标签: javascript generator redux-saga