Reactjs epic中的序列执行

Reactjs epic中的序列执行,reactjs,typescript,rxjs,Reactjs,Typescript,Rxjs,我需要修改史诗,以便在完成删除后调用其他操作,史诗 看起来像: const deleteComponentEpic: Epic< AppActions, AppActions, AppStore, ComponentDetailsEpicsDependencies > = (action$, _, { components }) => action$.pipe( filterAction(deleteComponentAction.request),

我需要修改史诗,以便在完成删除后调用其他操作,史诗 看起来像:

const deleteComponentEpic: Epic<
  AppActions,
  AppActions,
  AppStore,
  ComponentDetailsEpicsDependencies
> = (action$, _, { components }) =>
  action$.pipe(
    filterAction(deleteComponentAction.request),
    exhaustMap(action =>
      components.deleteComponent(action.payload.id).pipe(
        map(() => deleteComponentAction.success()),
        catchError((error: Error) => of(deleteComponentAction.failure(errorHandler(error)))),
      ),
    ),
  );

没有强迫你需要一对一的输入/输出比率。如果需要,可以使用mergeMap(也称为flatMap)发出多个动作。 你可以做以下事情-

components.deleteComponent(action.payload.id).pipe(
合并映射(()=>of(deleteComponentAction.success(),fetchCategoryComponentList()),
catchError((error:error)=>of(deleteComponentAction.failure(errorHandler(error)),
),
阅读此答案了解更多信息:

import { fetchCategoryComponentList } from '../../store';