应用程序如何离线工作

应用程序如何离线工作

本文介绍了Meteor 应用程序如何离线工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这在以下情况下很有用:

This is useful when:

  • 服务器已关闭,客户端无法连接以进行实时同步
  • 没有互联网连接
  • 用户不想上网,但想使用应用程序;

推荐答案

是的!大多数情况下,这已在 Meteor 中实现.

Yes! This is already implemented in Meteor, for the most part.

如果与服务器的连接丢失,客户端仍然可以在本地运行.数据库写入在客户端上似乎成功并立即反映在屏幕上.一旦重新建立连接,Meteor 将重新发送所有待处理的方法请求到服务器,并使用来自服务器的结果更新客户端显示.这都是延迟补偿的结果,离线被视为服务器很慢.

If the connection to the server is lost, the client can still function locally. Database writes will appear to succeed on the client and reflect instantly on the screen. Once the connection is re-established Meteor will re-send all the pending method requests to the server and update the client display with the results from the server. This is all the result of latency compensation, being offline is treated like the server just being very slow.

客户端可以监控反应性的Meteor.status()"输出以查看当前连接的状态.例如,您可以使用 Meteor.status 来驱动带有重新连接计时器和立即连接"按钮的弹出窗口,例如 gmail.

Clients can monitor the reactive 'Meteor.status()' output to see the status of the current connection. For example you could use Meteor.status to drive a popup with a reconnect timer and a 'connect now' button, like gmail.

当然,流星不是魔法.如果您在离线状态下点击重新加载"或离开页面等,您将丢失 Meteor 会话并且无法重新开始,直到您重新获得网络.不过,所有具有离线模式的网络应用都是如此,因此您的应用用户应该不会感到意外.

of course, Meteor isn't magic. If you hit 'reload', or navigate away from the page, etc, while offline you'll lose your Meteor session and not being able to start again until you regain network. This is true of all web apps with offline mode, though, so it shouldn't come as a surprise to users of your app.

这篇关于Meteor 应用程序如何离线工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 14:43