У меня есть эффект ngrx, подобный этому:
@Effect()
throwError$: Observable<Action> = this.actions$.pipe(
ofType<notificationActions.ErrorThrow>(
notificationActions.ActionTypes.ThrowError
),
tap(() => {
this.store.dispatch(new masterActions.LoadingHide());
this.sub = this.devTools.liftedState.subscribe(data => {
this.errorLogService.addErrorLog(JSON.stringify(data)).subscribe(data2 => console.log('data2', data));
console.log(JSON.stringify(data));
});
}),
map(action => action.payload),
tap(() => {
this.sub.unsubscribe();
}),
mergeMap(error => {
return of(
new notificationActions.ErrorAdd({
type: error.type,
description: error.description
})
);
})
);
метод addErrorLog в errorLogService отправляет HTTP-запрос на запись журнала ошибок в базу данных. Все работает, выполняя запрос, подобный этому, сначала запрос опций, а затем пост-запрос, но если я переключаюсь на switchMap для объединения обеих наблюдаемых, запрос опций отменяется, когда я проверяю его на вкладке сети в инструментах Chrome Dev.
Это часть кода, реорганизованная
tap(() => {
this.store.dispatch(new masterActions.LoadingHide());
this.sub = this.devTools.liftedState
.pipe(
switchMap(data => {
console.log('data', data);
return this.errorLogService.addErrorLog(JSON.stringify(data));
})
)
.subscribe();
})
какие-нибудь подсказки?