Created
January 14, 2018 05:02
-
-
Save shangyilim/8e11e29e7ccac7d0fd1316d4d3c71775 to your computer and use it in GitHub Desktop.
This file contains 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
// 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