How to implement a standalone single-user application with local storage Breeze.js and HTML5

I have a single page application using Breeze.js to access data. It uses Breeze.js to execute requests to the local cache, and data is requested only once at startup. After that, only data updates are sent to the server.

I am looking for a solution that allows me to report an application. If the mobile device does not have an Internet connection, the changes will be saved locally with the local repositories of Breeze.js and HTML5. When the mobile device reconnects to the network, the changes will be synchronized with the remote data store.

Any recommendations for meeting this requirement? thank

+5
source share
2 answers

HTML5 seems to provide 5 MB of local storage, which is stored until cleanup and is useful for storing JSON values ​​using XMLHttpRequest.

The 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() {   });

For more information, check Creating Hybrid Mobile Applications with HTML5

+2
source

@mitaka pointed out that connection changes were detected.

To use BreezeJS to save objects to local storage, the Export / Import topic in the BreezeJS documentation provides valuable hints. The file exportImportTests.js in the DocCode sample demonstrates some of the methods described there.

+1

All Articles