效果应获取有效载荷并在对话框中显示。 对话框关闭后,它应该发布内容并调度新操作。
问题是,在我关闭对话框之前,动作已被调度。
@Effect()
bookTable$ = this.actions$.pipe(
ofType(BookTableActionTypes.BOOK_TABLE),
map(action => action.payload),
exhaustMap((booking: Booking) => this.dialog.open(BookTableDialogComponent, {
width: this.window.responsiveWidth(),
data: booking.booking,
}).afterClosed()
.pipe( () => this.bookTableService.postBooking(booking),
map((res: any) => new BookTableSuccess(res)),
catchError(error => of(new BookTableFail({error: error})))
)));
.pipe( () => this.bookTableService.postBooking(booking),
map((res: any) => new BookTableSuccess(res)),
catchError(error => of(new BookTableFail({error: error})))
)));
以上代码仅应在对话框关闭后执行。
答案 0 :(得分:0)
似乎您在pipe
内缺少用于调用API的rxjs运算符。尝试switchMap
更改可观察范围。
.pipe(
switchMap(() => this.bookTableService.postBooking(booking)),
map((res: any) => new BookTableSuccess(res)),
catchError(error => of(new BookTableFail({error: error})))
);