Skip to content

Commit

Permalink
Step 3 | Load data from local storage
Browse files Browse the repository at this point in the history
  • Loading branch information
amahdy committed Mar 30, 2017
1 parent b70c0b7 commit d6a239d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/offline-first-app/offline-first-app.html
Expand Up @@ -37,11 +37,19 @@
value: new PouchDB('http://localhost:5984/personsdb'),
},

// Local DB, the synched version of `remoteDB`
localDB: {
type: PouchDB,
value: new PouchDB('local_personsdb'),
},

allDocs: Array, // All docs in the grid.
},

ready: function() {

PouchDB.replicate(this.remoteDB, this.localDB);

var grid = this.$.lazyGrid;

grid.columns = [
Expand All @@ -55,7 +63,7 @@
cell.element.textContent = cell.row.index;
};

this.remoteDB.allDocs().then(result => {
this.localDB.allDocs().then(result => {
this.allDocs = result.rows;

grid.items = (params, callback) => {
Expand All @@ -73,7 +81,7 @@

var data = [];
if(currentDocs.length > 0) {
this.remoteDB.bulkGet({
this.localDB.bulkGet({
docs: currentDocs,
}).then(json => {
for(var i=0; i<json.results.length; i++) {
Expand Down

0 comments on commit d6a239d

Please sign in to comment.