by Dale Harvey / @daleharvey
CACHE MANIFEST
# Mon May 18 2015 07:53:07 GMT+0000 (UTC)
/
/activity.html
/index.html
/install.html
/js/bundle.js
/style/icons/app-32.png
/style/icons/close.png
/style/icons/loading.png
NETWORK:
*
window.applicationCache.addEventListener('updateready', function(e) {
if (window.applicationCache.status ==
window.applicationCache.UPDATEREADY) {
window.location.reload();
}
});
<html><script src="framework.js" /></html>
localStorage.someData = 'foo';
localStorage.someData;
> "foo";
localStorage.someData = {'a': 'b'};
localStorage.someData;
> "[object Object]"
localStorage.someData = JSON.stringify({'a': 'b'});
var db = openDatabase('test', '0.1', 'A Database', 1024 * 1024);
db.transaction(function (t) {
t.executeSql('CREATE TABLE IF NOT EXISTS table (id INTEGER, name TEXT)');
t.executeSql('INSERT INTO table (name) VALUES (?)', ['FOO']);
t.executeSql("SELECT * FROM table", [], function(result) {
// results...
});
});
var open = window.indexedDB.open('database', 1);
open.onupgradeneeded = function(e) {
var db = e.target.result;
var store = db.createObjectStore('store', { keyPath: 'id' });
store.transaction.oncomplete = function() {
var txn = db.transaction('store', 'readwrite')
.objectStore('store').add({
id: 'someData',
foo: 'bar'
});
};
};
When you wake up to your daily commute on the tube / underground it would sure be nice to get through your morning emails
Spotify cant download the entire catalogue of music on every device, need to be able to pick which content to sync
It would be good to notify the user when new content is available, cant feasibly redownload all synced data on updates
I dont want my user to be losing data when they change the same data on seperate devices
var db = new PouchDB('database');
db.put({
_id : 'someData',
foo: 'bar'
});
db.allDocs().then(function(result) {
// result ...
});
var db = new PouchDB('db');
db.sync('http://example.org/cloud/db');