Closed JamesMcIntosh closed 5 years ago
From the look of the wrapInDispatch function the data will only be processed after writing to the server as then()
will only be called after saving.
https://github.com/prescottprue/redux-firestore/blob/master/src/utils/actions.js
@JamesMcIntosh How are you querying data? wrapInDispatch
shouldn't be used when attaching listeners (which calls setListener
and setListeners
), only when calling actions like get
. In the handling of listeners .then
is not used, the actual listener callbacks are.
It seems like the issue may be more with how state is being updated. How are you connecting to state? What does the query look like? Have you tried downgrading to 0.5.8
?
Thanks @prescottprue for your help, your question "How are you connecting to state" made me break it down further and I see now that the documents are indeed stored and made available.
My problem is caused by having a query which references a field which is set using the server timestamp... it is null until saved on the server, see https://github.com/firebase/firebase-js-sdk/issues/192
i.e. The following data will not be returned in the query when saved offline, it will appear once synced to the server.
const dataToSave = { created: firestore.FieldValue.serverTimestamp() };
const query = {
collection: 'testdata',
where: ['created', '>', yesterday]
};
When offline newly created documents are not returned in the results. Very shortly after I return online the documents appear in the results. Is this expected behaviour, if so how would I go about enhancing so that these pending documents are available? (I am using release redux-firestore version 0.6.0.)
Many thanks James