src/store/indexeddb.js
function IndexedDBStore(opts) {
    MemoryStore.call(this, opts);

    if (!opts.indexedDB) {
        throw new Error('Missing required option: indexedDB');
    }

    if (opts.workerScript) {
        // try & find a webworker-compatible API
        let workerApi = opts.workerApi;
        if (!workerApi) {
            // default to the global Worker object (which is where it in a browser)
            workerApi = global.Worker;
        }
        this.backend = new RemoteIndexedDBStoreBackend(
            opts.workerScript, opts.dbName, workerApi,
        );
    } else {
        this.backend = new LocalIndexedDBStoreBackend(opts.indexedDB, opts.dbName);
    }

    this.startedUp = false;
    this._syncTs = 0;

    // Records the last-modified-time of each user at the last point we saved
    // the database, such that we can derive the set if users that have been
    // modified since we last saved.
    this._userModifiedMap = {
        // user_id : timestamp
    };
}
function IndexedDBStore(opts) {
    MemoryStore.call(this, opts);

    if (!opts.indexedDB) {
        throw new Error('Missing required option: indexedDB');
    }

    if (opts.workerScript) {
        // try & find a webworker-compatible API
        let workerApi = opts.workerApi;
        if (!workerApi) {
            // default to the global Worker object (which is where it in a browser)
            workerApi = global.Worker;
        }
        this.backend = new RemoteIndexedDBStoreBackend(
            opts.workerScript, opts.dbName, workerApi,
        );
    } else {
        this.backend = new LocalIndexedDBStoreBackend(opts.indexedDB, opts.dbName);
    }

    this.startedUp = false;
    this._syncTs = 0;

    // Records the last-modified-time of each user at the last point we saved
    // the database, such that we can derive the set if users that have been
    // modified since we last saved.
    this._userModifiedMap = {
        // user_id : timestamp
    };
}
function IndexedDBStore ( opts ) { MemoryStore . call ( this , opts ) ; if ( ! opts . indexedDB ) { throw new Error ( 'Missing required option: indexedDB' ) ; } if ( opts . workerScript ) { // try & find a webworker-compatible API let workerApi = opts . workerApi ; if ( ! workerApi ) { // default to the global Worker object (which is where it in a browser) workerApi = global . Worker ; } this . backend = new RemoteIndexedDBStoreBackend ( opts . workerScript , opts . dbName , workerApi , ) ; } else { this . backend = new LocalIndexedDBStoreBackend ( opts . indexedDB , opts . dbName ) ; } this . startedUp = false ; this . _syncTs = 0 ; // Records the last-modified-time of each user at the last point we saved // the database, such that we can derive the set if users that have been // modified since we last saved. this . _userModifiedMap = { // user_id : timestamp } ; }
once every 5 minutes 
Construct a new Indexed Database store, which extends MemoryStore.

This store functions like a MemoryStore except it periodically persists
the contents of the store to an IndexedDB backend.

All data is still kept in-memory but can be loaded from disk by calling
<code>startup()</code>. This can make startup times quicker as a complete
sync from the server is not required. This does not reduce memory usage as all
the data is eagerly fetched when <code>startup()</code> is called.
<pre>
let opts = { localStorage: window.localStorage };
let store = new IndexedDBStore();
await store.startup(); // load from indexed db
let client = sdk.createClient({
store: store,
});
client.startClient();
client.on("sync", function(state, prevState, data) {
if (state === "PREPARED") {
console.log("Started up, now with go faster stripes!");
}
});
</pre>

@constructor
@extends MemoryStore
@param {Object} opts Options object.
@param {Object} opts.indexedDB The Indexed DB interface e.g.
<code>window.indexedDB</code>
@param {string=} opts.dbName Optional database name. The same name must be used
to open the same database.
@param {string=} opts.workerScript Optional URL to a script to invoke a web
worker with to run IndexedDB queries on the web worker. The IndexedDbStoreWorker
class is provided for this purpose and requires the application to provide a
trivial wrapper script around it.
@param {Object=} opts.workerApi The webWorker API object. If omitted, the global Worker
object will be used if it exists.
@prop {IndexedDBStoreBackend} backend The backend instance. Call through to
this API if you need to perform specific indexeddb actions like deleting the
database.
once every 5 minutes Construct a new Indexed Database store which extends MemoryStore .