在Redux中保持epic可观察,直到收到操作

在Redux中保持epic可观察,直到收到操作,redux,rxjs,redux-observable,Redux,Rxjs,Redux Observable,我不熟悉rxjs和redux观测值 我有两部史诗: export const appInit = action$ => action$.ofType(actions.appInitRequest) .take(1) .switchMap(() => actions.fetchData()) 及 App Init触发操作以获取数据, 是否可以在获取数据完成之前保持导航epic?因此,如果收到导航操作并且获取数据未完成,我们将等待获取数据完成(dispatch action

我不熟悉rxjs和redux观测值

我有两部史诗:

export const appInit = action$ =>
  action$.ofType(actions.appInitRequest)
  .take(1)
  .switchMap(() => actions.fetchData())

App Init触发操作以获取数据, 是否可以在获取数据完成之前保持导航epic?因此,如果收到导航操作并且获取数据未完成,我们将等待获取数据完成(dispatch action.fetchDataSuccess),然后继续导航流程

我尝试了以下代码,但在FetchDataSucces之后的每个请求都会等待新的FetchDataSucces

export const navigation = ($action, {getState}) =>
  $action.ofType(actions.locationChange)
    .switchMap(({payload: {pathname}}) =>
      $action.ofType(action.fetchDataSuccess)
      .take(1)
尝试使用:

export const导航=($action,{getState})=>
$action.of类型(actions.locationChange)
.withLatestFrom(appInit)
.filter(([locationChangeEvent,appInitEvent])=>{
return/*检查应用程序是否已成功初始化*/
})
.map(([locationChangeEvent])=>locationChangeEvent)
.do(console.log)
export const navigation = ($action, {getState}) =>
  $action.ofType(actions.locationChange)
    .switchMap(({payload: {pathname}}) =>
      $action.ofType(action.fetchDataSuccess)
      .take(1)