Last active
March 21, 2020 21:21
-
-
Save NyaGarcia/30c94926b5374e6c1bf611b4e03a2a89 to your computer and use it in GitHub Desktop.
Using takeUntil to force observables to complete
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
const stop$ = new Subject<void>(); | |
trainer$ | |
.pipe(takeUntil(stop$)).subscribe(trainer => { | |
// Do something with trainer | |
}); | |
pokemon$ | |
.pipe(takeUntil(stop$)).subscribe(pokemon => { | |
// Do something with pokemon | |
}); | |
number$ | |
.pipe(takeUntil(stop$)).subscribe(number => { | |
// Do something with number | |
}); | |
function stop() { | |
stop$.next(); | |
stop$.complete(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment