RxJS Operators

In the .pipe( you can call any of these operators

filter

1
2
3
4
5
6
7
8
// filter to check the something comes back and properties are set
filter(storeItem => storeItem && !!storeItem.item),

// filter on a bool
filter(a => a.isLoading === false),

// filter that SOMETHING came back
filter(Boolean),

tap

1
2
// quick tap to display whats coming back
tap(a => console.log(a)),

distinctUntilChanged

1
2
3
4
5
6
7
8
9
10
11
// only fire down to the `subscribe` when `item.listingId` changes
distinctUntilChanged((prev, curr) => prev.item.listingId === curr.item.listingId)

// Example
this._listingFacade.getCurrentListing().pipe(
takeUntil(this._destroyed$),
filter(storeItem => storeItem && !!storeItem.item),
distinctUntilChanged((prev, curr) => prev.item.listingId === curr.item.listingId)
).subscribe(storeItem => {
// do something, this was usewful when resetting state
});

References