I am able to setup redux-observable with normal Firestore queries
export const getStatementsEpic = (action$, store) => {
return action$.ofType(GET_STATEMENTS)
.filter(() => {
const state = store.getState()
return state.auth.user
})
.mergeMap(() => {
console.log('action', store.getState().auth.user.uid)
const db = firebase.firestore()
db.settings({ timestampsInSnapshots: true })
const query = db.collection('users')
.doc(store.getState().auth.user.uid)
.collection('statements')
.orderBy('uploadedOn', 'desc')
.limit(50)
return query.get().then(snapshot => {
console.log('Should have gotten snapshot')
return getStatementsSnapshot(snapshot)
})
})
}
But I want to convert this to be realtime, I tried changing
return query.get().then(snapshot => {
to
return query.onSnapshot(snapshot => {
But it does not work ... I guess this is not a promise? How do I resolve this?