5

I have a question about Firebase's offline capabilities for JavaScript. Specifically, I am wondering if one were to lose connection while filling out a form on a web application (powered by firebase, obviously), and then try to send that form, would it perform a write operation to the local database, and then catch up with the server when connection is re-established, or would that data be lost? If this is a yes, I am assuming that it does not matter if the user exits out of the page, as long as the form as sent.

I know that it offers tremendous disk persistence for its iOS and Android SDKs, however I am just trying to get a better handle on how this can help in JavaScript. I am aware of the onDisconnectclass, and that it should mainly be used to manage the presence of a users as well - Just has this on mind for a while!

Thanks !

Renan Araújo
  • 3,533
  • 11
  • 39
  • 49
Thomas Greco
  • 122
  • 1
  • 11

1 Answers1

6

Firebase supports two types of offline mode:

  1. in case of intermittent loss of connectivity, the client will keep serving events from the local data and any writes will be queued. When the connection is restored, all writes are sent to the server and any stale data is resynchronized. We often call this "tunnel mode".

  2. The mobile native (iOS and Android) clients can be configured through their API to store all data on the local disk. In case of prolonged loss of connectivity, these clients will then queue writes on disk too. The client will also be able to serve data from this disk cache, when the app is restarted. This one we often call "airplane mode".

Tunnel mode is available in all Firebase SDKs. Airplane mode is only available in Firebase's native mobile SDKs for Android and iOS.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Thank you for your response! So just to be sure, this form info would be queued, and then sent upon being re-established. And does this work if a user exits out of the web application? – Thomas Greco Sep 11 '15 at 21:21
  • Nope. That would be "airplane mode", which is only available for mobile native SDKs (Android and iOS). – Frank van Puffelen Sep 11 '15 at 22:32
  • Awesome thank you so much. I did not think that was the case, however I am publishing an article on Firebase's offline capabilities and wanted to make sure I had my facts straight. – Thomas Greco Sep 12 '15 at 23:26