rxEffect
rxEffect
is a utility function that helps you create a side effect with rxjs, returning an already well handled Subscription
with takeUntilDestroyed
within it.
The effect logic can either:
- be set as the second argument as a
TapObserver
ornext
function - or be handled directly within the source (less encouraged but you could need to do that if your effect needs to be within a
switchMap
or similar)
arguments | type | description |
---|---|---|
source | Observable<T> | Any Observable that will be subscribed to, to execute the side effect |
effectOrOptions | TapObserver<T> | ((value: T) => void) | { destroyRef: DestroyRef } | Optional. Default is undefined .A next handler, a partial observer or an options object. |
options | { destroyRef: DestroyRef } | Optional. Default is undefined .An options object there to provide a DestroyRef if need. |
Usage
With the next
function
With a TapObserver
With the effect handled directly within the source