Created
April 28, 2022 07:36
-
-
Save yjaaidi/56e941683b06a09812b93e837c120c50 to your computer and use it in GitHub Desktop.
RxJS waitLatestForm
This file contains hidden or 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
import { switchMap } from 'rxjs/operators'; | |
action$; | |
state$; // facade.country$ etc... | |
repository$; | |
fetch$.pipe(withLatestFrom(facade.country$)); | |
waitLatestFrom = (action$) => | |
action$.pipe( | |
switchMap((action) => | |
combineLatest(of(action), facade.country$.pipe(take(1))) | |
) | |
); | |
waitLatestFrom = (action$) => | |
action$.pipe(concatLatestFrom(() => facade.country$.pipe(take(1)))); | |
fetch$.pipe( | |
switchMap( | |
(action) => country$.pipe(take(1)), | |
map((country) => ({ ...action, country })) | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment