我需要修改一个epic,以便在完成删除后调用额外的操作,epic看起来像:
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)))),
),
),
);删除成功需要调用以下动作,该怎么做?下面是我的操作的导入:
import { fetchCategoryComponentList } from '../../store';发布于 2021-01-29 02:17:31
没有强制要求您需要一对一的输入/输出比率。如果需要,您可以使用mergeMap (也称为flatMap)发出多个操作。您可以执行以下操作-
components.deleteComponent(action.payload.id).pipe(
mergeMap(() => of(deleteComponentAction.success(), fetchCategoryComponentList())),
catchError((error: Error) => of(deleteComponentAction.failure(errorHandler(error)))),
),有关更多信息,请阅读以下答案:https://stackoverflow.com/a/40895613/11167389
https://stackoverflow.com/questions/65942805
复制相似问题