Skip to content

Instantly share code, notes, and snippets.

@shangyilim
Created January 14, 2018 05:01
Show Gist options
  • Save shangyilim/c88fa19ab535a97c03519749d0ebe78d to your computer and use it in GitHub Desktop.
Save shangyilim/c88fa19ab535a97c03519749d0ebe78d to your computer and use it in GitHub Desktop.
// Query for California
var californiaRef = citiesRef.where("state", "==", "CA");
// Query for Colorado
var coloradoRef = citiesRef.where("state", "==", "CO");
// Create Observables.
var california$ = new Rx.Subject();
var colorado$ = new Rx.Subject();
// Hook values from callback to the observable
californiaRef.onSnapshot((querySnapshot) => {
var data = querySnapshot.docs.map(d => d.data());
california$.next(data);
});
coloradoRef.onSnapshot((querySnapshot) => {
var data = querySnapshot.docs.map(d => d.data());
colorado$.next(data);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment