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)