? ? 場景:我需要在effects的某個方法里面延遲5秒再調(diào)用這個方法,但是直接使用
settimout(()=>{
yield put({})
?},5000)
直接這樣寫會報yield undefind
解決方案:就是在這個modal方法外面定義一個方法屯换,里面調(diào)用settimeout方法
const delay = (ms) => new Promise((resolve) => {
? setTimeout(resolve, ms);
});
然后在effects的方法里面調(diào)用炒辉,然后在yield put你要調(diào)用的方法
yield call(delay, 3000);
?yield put({ })