Skip to content

Instantly share code, notes, and snippets.

@shangyilim
Created January 14, 2018 05:02
Show Gist options
  • Save shangyilim/8e11e29e7ccac7d0fd1316d4d3c71775 to your computer and use it in GitHub Desktop.
Save shangyilim/8e11e29e7ccac7d0fd1316d4d3c71775 to your computer and use it in GitHub Desktop.
// When either California OR Colorado values are emitted from their queries,
// combine both observables
var californiaOrColorado$ = Rx.Observable.combineLatest(california$, colorado$).switchMap((cities) => {
// Destructure the values to combine a single array.
var [californiaCities, coloradoCities] = cities;
var combined = [
//spread the arrays out to combine as one array
...californiaCities,
...coloradoCities
]
// Return as a new Observable that contains the combined list.
return Rx.Observable.of(combined);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment