如何使用Breeze.js和HTML5本地存储实现具有脱机功能的单页应用程序 [英] How to implement offline capable Single Page Application with Breeze.js and HTML5 local storage

查看:247
本文介绍了如何使用Breeze.js和HTML5本地存储实现具有脱机功能的单页应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Breeze.js进行数据访问的单页应用程序。它使用Breeze.js对本地缓存执行查询,并且在启动时仅请求一次数据。之后只有数据更新在服务器上回发。

I have working Single Page Application using Breeze.js for Data Access. It uses the Breeze.js to execute queries against the local cache and the data is requested only once at start up. Only the data updates are posted back on the server afterwards.

我正在寻找一种解决方案来提高应用程序连接。如果移动设备没有互联网连接,则将使用Breeze.js和HTML5本地存储在本地保存更改。当移动设备重新联机时,更改将同步到远程数据存储。

I am looking for a solution to make the application connection aware. If the mobile device does not have internet connection the changes will be saved locally with Breeze.js and HTML5 local storage. When the mobile device is back online the changes will be synched to the remote data storage.

任何指导如何实施该要求?
谢谢

Any guidelines how to implement that requirement? Thanks

推荐答案

看起来HTML5提供5MB本地存储,它一直存在直到清理完毕并且对存储JSON值很有用使用XMLHttpRequest。

Looks like the HTML5 provides 5MB local storage, which persists until cleaned and is useful for storing JSON values with XMLHttpRequest.

HTML 5 navigator.onLine属性提供离线检测。如果在线则为真,否则为假

HTML 5 navigator.onLine property provides offline detection. True if online, false if not

 var nav = window.navigator;
 if(nav.onLine) {
    // do HMLHttpRequests etc
 }
 window.addEventListener('online', function() {   });
 window.addEventListener('offline', function() {   });

有关更多信息,请查看使用HTML5构建混合移动应用程序

For more information check Building Hybrid Mobile Applications with HTML5

这篇关于如何使用Breeze.js和HTML5本地存储实现具有脱机功能的单页应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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