Skip to content

Instantly share code, notes, and snippets.

@NyaGarcia
Last active March 21, 2020 21:21
Show Gist options
  • Save NyaGarcia/30c94926b5374e6c1bf611b4e03a2a89 to your computer and use it in GitHub Desktop.
Save NyaGarcia/30c94926b5374e6c1bf611b4e03a2a89 to your computer and use it in GitHub Desktop.
Using takeUntil to force observables to complete
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