Skip to content

Instantly share code, notes, and snippets.

@NyaGarcia
Last active March 21, 2020 20:35
Show Gist options
  • Save NyaGarcia/a48e9cfdd433af06bfd1c4ada9ed6541 to your computer and use it in GitHub Desktop.
Save NyaGarcia/a48e9cfdd433af06bfd1c4ada9ed6541 to your computer and use it in GitHub Desktop.
Manually unsubscribing from multiple observables
const pokemonSubscription = pokemon$.subscribe(pokemon => {
// Do something with pokemon
});
const trainerSubscription = trainer$.subscribe(trainer => {
// Do something with trainer
});
const numberSubscription = number$.subscribe(number => {
// Do something with number
});
function stop() {
pokemonSubscription.unsubscribe();
trainerSubscription.unsubscribe();
numberSubscription.unsubscribe();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment