我們的應用程序使用ATTEMPT - SUCCESS - FAILURE方法處理來自服務器的響應。只有當一個不同的傳奇完成時,你能否稱爲傳奇並繼續執行?
我有一個需要這樣的表現發電機功能:
function * getSingleSectorAttempt(action) {
const sectors = yield select(getSectors);
if (!sectors) {
//If there are no sectors, I need to call the GET_SECTORS_ATTEMPT action
//and only restart/continue this saga when the GET_SECTORS_SUCCESS action is fired
}
const id = sectors[action.name].id;
try {
const response = yield call(api.getSector, id);
//...
} catch (err) {
//...
}
}
從我讀過的終極版佐賀的文檔,這似乎並沒有立即成爲可能。但是,我想看看我是否錯過了一些東西。在if(!sectors)
條件塊
yield fork(takeLatest, Type.GET_SECTORS_SUCCESS, getSingleSectorAttempt);
yield put(Actions.getSectorsAttempt());
,但在這工作不堅持最初的GET_SINGLE_SECTOR_ATTEMPT
動作參數,我不知道如何得到它這樣做沒有進入回調:我已經試過這和論據意大利麪條。