Created
February 29, 2020 12:23
-
-
Save NyaGarcia/27ef1135f269f0f970227b285ecb6112 to your computer and use it in GitHub Desktop.
Storing subscriptions in an array for easier tracking
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 trainerSubscription = trainer$.subscribe(trainer => { | |
// Do something with trainer | |
}); | |
const pokemonSubscription = pokemon$.subscribe(pokemon => { | |
// Do something with pokemon | |
}); | |
const numberSubscription = number$.subscribe(number => { | |
// Do something with number | |
}); | |
let subscriptions: Subscription[]; | |
// Immutably adding subscriptions | |
subscriptions = [ | |
...subscriptions, | |
pokemonSubscription, | |
trainerSubscription, | |
numberSubscription | |
]; | |
subscriptions.map(subscription => subscription.unsubscribe()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment