流星应用程序如何离线工作? [英] How can Meteor apps work offline?

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

问题描述

这在以下情况下很有用:

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.

当然,流星不是魔术.如果您在离线状态下点击重新加载"或离开页面导航等,则您将失去流星会话,直到重新获得网络后才能重新开始.但是,对于所有具有脱机模式的Web应用程序都是如此,因此对于您的应用程序用户来说应该不会感到惊讶.

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.

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

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