参考:https://dvajs.com/guide/introduce-class.html#reducer
const delay = (timeout) => {
return new Promise(resolve => {
setTimeout(resolve,timeout)
})
}
effects: {
// 定义promise
* Interval({
payload={},
}, { put, call, select }){
//60秒倒计时...
let i= 60
while(i>0){
i--;
yield call(delay, 1000); //参考https://dvajs.com/guide/introduce-class.html#reducer
yield put({
type: 'updateState',
payload:{
count:i
}
})
}
}
}
网友评论