I am attempting to make several HTTP requests in response to a click on an "Update All" button. My code looks like this:
let new_items:Observable<ApiResponse<ShoppingListItem>>[] = this.items
.map(item => new ShoppingListItem(...))
.map(item => this.shoppingListService.updateItem(item));
concat(new_items).subscribe(
r => console.log(r);
);
this.shoppingListService.updateItem returns the Observable generated by calling httpClient.put.
When this code is run, I expect to see the value printed by console.log(r) to be of the type produced by the updateItem method. Instead, it's an Observable. My server logs indicate that no HTTP request was made. This seems to indicate that it wasn't subscribed to. My understanding of the concat docs is that each individual Observable passed to concat will be subscribed in sequence when the Observable before it completes.
If I replace concat with forkJoin I get the result I was expecting. I don't particularly care about order, so I am fine using forkJoin but I want to understand why using concat didn't work.
concat(...new_items). It might be a bug withrxjsor a bug with their documentation :-). It sounds like it should allow an array as input, but I see what you've mentioned, that the subscription getsObservablenot the emitted type. StackBlitz - BizzyBobconcat(...new_items).subscribe()outputs the responses from the HTTP requests. Write this up as an answer and I'll accept it. - ryanmcfall