Created
January 14, 2018 05:01
-
-
Save shangyilim/c88fa19ab535a97c03519749d0ebe78d 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
// 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