Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Child pages (Children Display)
alltrue
depth3
excerpttrue

BIC: persistent storage

excerptTypesimple

For more information on BIC-JQM persistent storage and the newest of the persistent storage APIs click here

 What's out?

Our collections avoid using any of the following mechanisms by default:

...

  1. check to see if the BIC has loaded

  2. check to see whether the collections exist

  3. check to see whether we have detected reliable persistent storage (per-above)

Code Block

...

languagejs
titleExample
linenumberstrue
require(['bic'], function (bic) { // 1.
  bic.collections().then(function () { // 2.
    if (bic.hasStorage()) { // 3.
      // TODO: do something with a persistent collection
      // e.g. `bic.interactions`, `bic.pending`, etc
    }
  });
});

 

We list our persistent collections with our other publicly accessible values.

...

If you use these, then you can be certain that PouchDB has persisted your data to device storage. For example:

Code Block
languagejs
titleExample
linenumberstrue
require(['bic'], function (bic) {
  bic.collections().then(function () {
    if (bic.hasStorage()) {
      var pendingRecord = {
        type: 'Form',
        status: 'Draft',
        name: 'MyFormName',
        label: 'My Friendlier Form Name',
        action: 'add',
        answerspaceid: BMP.BIC.siteVars.answerSpaceId,
        data: {
          /* TODO: this is where the pending record data would go */
        }
      };
      var createOptions = {};
      createOptions.success = function () {
        // TODO: do something after persistence is complete
      };
      createOptions.error = function (err) {
        // TODO: do something with `err`
      }
      bic.pending.create(pendingRecord, createOptions);
    }
  });
});