本人刚学saga 望详细解答 谢谢。
export function* requestTypeList() {
try {
yield put(fetchTypeList());
const typeList = yield call(request, WEXIN_ARTICLE_TYPE, 'get');
yield put(receiveTypeList(typeList.showapi_res_body.typeList));
yield call(store.save, 'typeList', typeList.showapi_res_body.typeList);
const errorMessage = typeList.showapi_res_error;
if (errorMessage && errorMessage !== '') {
yield ToastUtil.showShort(errorMessage);
}
} catch (error) {
yield put(receiveTypeList([]));
yield ToastUtil.showShort('网络发生错误,请重试');
}
}
export function* watchRequestTypeList() {
while (true) {
yield take(types.REQUEST_TYPE_LIST);//请问这个take起什么作用?监听嘛?如果是可以用takeevery替换?
yield fork(requestTypeList);
}
}
相关分类