Skip to content

Instantly share code, notes, and snippets.

@NyaGarcia
Last active March 22, 2020 20:10
Show Gist options
  • Select an option

  • Save NyaGarcia/4c0c5476d67d6e363584c00266c3dcd1 to your computer and use it in GitHub Desktop.

Select an option

Save NyaGarcia/4c0c5476d67d6e363584c00266c3dcd1 to your computer and use it in GitHub Desktop.
Fixing nested subscribes with the switchMap operator
getTrainer()
.pipe(
switchMap(trainer => getStarterPokemon(trainer))
)
.subscribe(pokemon => {
// Do stuff with pokemon
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment