-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在effect里setInterval定时修改状态时,yield put不起作用 #1527
Comments
不能用 setInterval(() => {}) |
应该把setInterval(() => {})封装成一个异步函数然后yield吧 |
大佬能帮忙详细说说吗? |
const delay = ms => new Promise(resolve => setTimeout(resolve, ms))
// or import { delay } from 'redux-saga'
* foo_effect({ payload }, { put }) {
while (true) {
console.log('baz')
yield put({ type: 'foo_reducer' })
yield delay(1000)
}
} 这应该能实现你想要的结果,请多查看redux-saga的文档 |
@objectisundefined 有另外的代码会取消的,在这里没写出来 - - |
@objectisundefined while(true) 路子有点野 - -,这样后续还想执行别的代码就不行了 |
@miaojiuchen |
jnotnull/dva-generator#2 (comment) effects中在回调中执行其他effects |
我往foo_effect的payload中传入参数,根据参数判断是否继续定时请求,这种做法不行,该怎么改?@objectisundefined |
baz能被打印出来,但是foo_reducer没有被执行,求助
The text was updated successfully, but these errors were encountered: