2
我是新來rxjs和終極版,觀測保持史詩可觀察到的動作收到
我有兩個史詩:
export const appInit = action$ =>
action$.ofType(actions.appInitRequest)
.take(1)
.switchMap(() => actions.fetchData())
和
export const navigation = ($action, {getState}) =>
$action.ofType(actions.locationChange)
.do(console.log)
應用程序初始化觸發動作獲取數據, 是否有可能持有導航史詩至獲取數據完成?所以如果接收到導航動作並且獲取數據沒有完成,我們將等到獲取數據完成(dispatch action.fetchDataSuccess)並繼續導航史詩流程?
我試着下面的代碼,但比fetchDataSuccess後的每個請求等待新fetchDataSuccess
export const navigation = ($action, {getState}) =>
$action.ofType(actions.locationChange)
.switchMap(({payload: {pathname}}) =>
$action.ofType(action.fetchDataSuccess)
.take(1)