Skip to content

Instantly share code, notes, and snippets.

@shangyilim
Created January 14, 2018 05:05
Show Gist options
  • Save shangyilim/d5d809bcea04e7fb88d754e027acc7ea to your computer and use it in GitHub Desktop.
Save shangyilim/d5d809bcea04e7fb88d754e027acc7ea to your computer and use it in GitHub Desktop.
caOrCoCities$: Observable<City[]>;
...
const californiaRef = this.angularFirestore
.collection("cities", ref => ref.where("state","==","CA"));
const coloradoRef = this.angularFirestore
.collection("cities", ref => ref.where("state","==","CO"));
this.caOrCoCities$ = Observable
.combineLatest(californiaRef.valueChanges(),
coloradoRef.valueChanges())
.switchMap(cities => {
const [californiaCities, coloradoCities] = cities;
const combined = californiaCities.concat(coloradoCities);
return Observable.of(combined);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment