【发布时间】:2019-02-21 06:11:52
【问题描述】:
正在学习 Saga 事件通道以侦听自定义事件,但无法解决问题。
问题: startlistner() 函数在调用时不会从根函数调用
const channel = yield call(startlistner);
完整代码
import { eventChannel } from "redux-saga";
import { take, fork, call } from "@redux-saga/core/effects";
export default function handleclick() {
root().next();
}
function* root() {
const channel = yield call(startlistner);
while (true) {
const { data } = yield take(channel);
console.log("while");
}
}
function startlistner() {
console.log("da");
const channel = eventChannel(emmiter => {
emmiter({ data: null });
return () => {};
});
}
感谢您提供的任何帮助。
【问题讨论】:
标签: reactjs typescript react-redux redux-saga