order.service.ts
process(order: Order): Observable<Order[] | null> {
console.log("Initiating processing")
return this.orders$.pipe(
take(1),
switchMap((orders) =>
console.log("Inside switchmap")
this._httpClient
.post<Order>(this.baseUrl + 'process/', order, this.httpOptions)
.pipe(
map((newOrder) => {
const result = [{ ...newOrder, ...orders }];
this._orders.next(result);
return result;
})
)
)
);
}
order.component.ts
submit() {
const dialogRef = this.dialog.open(CreateOrderComponent, {
data: {},
width: '50%',
disableClose: true
});
dialogRef
.afterClosed()
.pipe(
filter(Boolean),
tap((order) => this._orderService.process(order)),
takeUntil(this._destroy)
)
.subscribe();
}
I am encountering a problem where the switchmap does not log anything. However, when I submit my order, I can see the new order in the console. There is no HTTP request to the backend or any request logs in Chrome. I have also tried using pre-existing orders but to no avail. Any assistance on this issue would be greatly appreciated. Thank you.