Firebase JavaScript API在重新连接时与服务器保持同步吗? [英] Does Firebase JavaScript API catch-up with server when re-connected

查看:79
本文介绍了Firebase JavaScript API在重新连接时与服务器保持同步吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于Firebase的JavaScript离线功能的问题。具体来说,我想知道在Web应用程序(显然是由firebase提供的)填写表单时是否会失去连接,然后尝试发送该表单,是否会对本地数据库执行写入操作,然后捕获当连接重新建立时与服务器联系起来,还是会丢失数据?如果这是肯定的,我假设用户退出页面并不重要,只要发送表单。

我知道它为iOS和Android SDK提供了巨大的磁盘持久性,但是我只是想更好地处理如何在JavaScript中提供帮助。我知道 onDisconnect 类,它应该主要用于管理用户的存在 - 只是有这个想法一会儿!



谢谢! Firebase支持两种离线模式:

    $ b

    解决方案

    $ b

  1. 在间歇性连接丢失的情况下,客户端将继续从本地数据服务事件,并且任何写入将排队。当连接恢复时,所有的写操作都被发送到服务器,任何陈旧的数据都会被重新同步。我们经常称之为隧道模式。

  2. 移动原生(iOS和Android)客户端可以通过它们的API进行配置,以将所有数据存储在本地磁盘上。如果长时间连接丢失,则这些客户端也会将写入操作排队在磁盘上。当应用程序重新启动时,客户端也将能够从这个磁盘缓存中提供数据。这个我们经常称之为飞行模式。




  3. 隧道模式适用于所有Firebase SDK。飞行模式仅适用于Android和iOS的Firebase原生移动SDK。


    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 !

    解决方案

    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.

    这篇关于Firebase JavaScript API在重新连接时与服务器保持同步吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆