Created
October 27, 2017 15:35
-
-
Save mfp22/be6f34dacf66c06eca4daa32039e914e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public muteFirst = <T,R>(first$: Observable<T>, second$: Observable<R>) => Observable.combineLatest( | |
first$, | |
second$, | |
(a,b) => b | |
).distinctUntilChanged(); |
If you have something that is triggered by second$
changing, that distinctUntilChanged
can be vital. Else, that event will be triggered when first$
emits also.
If you don't want distinctUntilChanged
on b
but also don't want updates when a
changes, I think this is an alternative:
public muteFirst = <T,R>(first$: Observable<T>, second$: Observable<R>) => second$.withLatestFrom(
first$,
(b, a) => b
);
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
muteFirst is a helper that joins two levels of dependency together: From the server to the store via first$, and from the store to the component via second$.