Matthew Mullin
Matthew Mullin

Reputation: 7636

Firestore Offline Promise Handling?

I have been scouring the firestore docs and the angularfire2 docs looking for any information regarding how firebase/angularfire handles it's write promises when my progressive web app is offline.

The problem is that all of my promises returned from the batch writes are not being resolved (or rejected), so should I be assuming that all promises made offline will be resolved? If so, am I correct in saying I should rather be handling redirects and success messages before the promise is resolved?

Besides my unresolved firebase promises, the offline mode seems to work well. It correctly changes data in various places throughout many collections and documents, and the changes are displayed correctly in the web app.

Once returning to online mode, the relevant changes are made to the database and my pending promises all seem to get resolved at once.

Is this expected behaviour? And if it is what would the correct way about handling success/error messages and redirects be (if they were previously handled in the promise then and catch)

Upvotes: 2

Views: 845

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598728

Firestore promises (and completion handlers on other platforms) indeed resolve/reject when the write operation has been committed/rejected on the server. So what you see is indeed the expected behavior.

Upvotes: 2

Related Questions