There is an Observable of the array of places:
places: Observable>;
In template it used with the async pipe:
RxJS version 6
Using the accepted answer with RxJS 6 and typescript will throw an error because the observables hold different types. you better use combineLatest, you could also use zip but it will not work! did you just ask why? the answer is here :)
combineLatest([
this.items$,
this.deleteItem$
]).pipe(
takeUntil(this.onDestroy),
tap(([items, deleteItem]) => {
if (deleteItem && deleteItem.op === 'deleteItem') {
var index = items.findIndex((item) => item.id === deleteItem.id);
if (index >= 0) {
items.splice(index, 1);
}
return items;
}
else {
return items.concat(deleteItem);
}
})
).subscribe();
then you can send the event..
this.deleteItem$.next({ op: 'deleteItem', id: '5e88fce485905976daa27b8b' });
I hope it will help someone..