你好,我有效果
@Effect({dispatch: false})
createSomething$ = this._actions$.pipe(
ofType(
clientsActions.Create),
mergeMap((action) => this._service.add(action.payload)
.pipe(
tap(() => this._router.navigate(['somewhere'])),
catchError(error => of())
))
);
这很好,效果发送请求并重定向,但是现在我想添加,当我尝试做类似的事情
时,其他类的操作@Effect({dispatch: false})
createSomething$ = this._actions$.pipe(
ofType(
clientsActions.Create),
mergeMap((action) => this._service.add(action.payload)
.pipe(.map(() => ({type: this.otherActions.doAction),
tap(() => this._router.navigate(['somewhere'])),
catchError(error => of())
))
);
这不起作用,其他动作也无能为力,甚至没有在开发工具中显示,现在我感到困惑。我也尝试了concatmap等。
使用Mergemap并返回数组[{type:actionType}]
@Effect({dispatch: false})
createSomething$ = this._actions$.ofType(clientsActions.Create)
.pipe(
mergeMap((action) => this._service.add(action.payload).pipe(
mergeMap(() => ([{type: this.otherActions.doAction}]),
tap(() => this._router.navigate(['somewhere'])),
catchError(error => of())
))
);