How to use the dexie.vip function in dexie

To help you get started, we’ve selected a few dexie examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dfahlander / Dexie.js / addons / Dexie.Observable / src / Dexie.Observable.js View on Github external
function poll() {
        pollHandle = null;
        var currentInstance = mySyncNode.id;
        Dexie.vip(function() { // VIP ourselves. Otherwise we might not be able to consume intercomm messages from master node before database has finished opening. This would make DB stall forever. Cannot rely on storage-event since it may not always work in some browsers of different processes.
            readChanges(Observable.latestRevision[db.name]).then(cleanup).then(consumeIntercommMessages).finally(function() {
                // Poll again in given interval:
                if (mySyncNode && mySyncNode.id === currentInstance) {
                    pollHandle = setTimeout(poll, LOCAL_POLL);
                }
            });
        });
    }
github dfahlander / Dexie.js / addons / Dexie.Observable / src / Dexie.Observable.js View on Github external
function onSuicide(dbname, nodeID) {
        if (dbname === db.name && !Observable.wereTheOneDying) {
            // Make sure it's dead indeed. Second bullet. Why? Because it has marked itself for deletion in the onbeforeunload event, which is fired just before window dies.
            // It's own call to put() may have been cancelled.
            // Note also that in IE, this event may be called twice, but that doesnt harm!
            Dexie.vip(function() {
                db._syncNodes.update(nodeID, { deleteTimeStamp: 1, lastHeartBeat: 0 }).then(cleanup);
            });
        }
    }
github dfahlander / Dexie.js / addons / Dexie.Syncable / src / Dexie.Syncable.js View on Github external
PersistedContext.prototype.save = function () {
                        // Store this instance in the syncContext property of the node it belongs to.
                        return Dexie.vip(function () {
                            return node.save();
                        });
                    };
github dfahlander / Dexie.js / addons / Dexie.Observable / src / Dexie.Observable.js View on Github external
function onSuicide(dbname, nodeID) {
        if (dbname === db.name && !Observable.wereTheOneDying) {
            // Make sure it's dead indeed. Second bullet. Why? Because it has marked itself for deletion in the onbeforeunload event, which is fired just before window dies.
            // It's own call to put() may have been cancelled.
            // Note also that in IE, this event may be called twice, but that doesnt harm!
            Dexie.vip(function() {
                db._syncNodes.update(nodeID, { deleteTimeStamp: 1, lastHeartBeat: 0 }).then(cleanup);
            });
        }
    }
github dfahlander / Dexie.js / addons / Dexie.Observable / src / Dexie.Observable.js View on Github external
function poll() {
        pollHandle = null;
        var currentInstance = mySyncNode.id;
        Dexie.vip(function() { // VIP ourselves. Otherwise we might not be able to consume intercomm messages from master node before database has finished opening. This would make DB stall forever. Cannot rely on storage-event since it may not always work in some browsers of different processes.
            readChanges(Observable.latestRevision[db.name]).then(cleanup).then(consumeIntercommMessages)
            .catch('DatabaseClosedError', e=>{
                // Handle database closed error gracefully while reading changes.
                // Don't signal 'unhandledrejection'.
                // Even though we intercept the close() method, it might be called when in the middle of
                // reading changes and then that flow will cancel with DatabaseClosedError.
            })
            .finally(function() {
                // Poll again in given interval:
                if (mySyncNode && mySyncNode.id === currentInstance) {
                    pollHandle = setTimeout(poll, LOCAL_POLL);
                }
            });
        });
    }
github dfahlander / Dexie.js / addons / Dexie.Observable / dist / dexie-observable.es6.js View on Github external
function poll() {
        pollHandle = null;
        var currentInstance = mySyncNode.id;
        Dexie.vip(function () {
            // VIP ourselves. Otherwise we might not be able to consume intercomm messages from master node before database has finished opening. This would make DB stall forever. Cannot rely on storage-event since it may not always work in some browsers of different processes.
            readChanges(Observable.latestRevision[db.name]).then(cleanup).then(consumeIntercommMessages).finally(function () {
                // Poll again in given interval:
                if (mySyncNode && mySyncNode.id === currentInstance) {
                    pollHandle = setTimeout(poll, LOCAL_POLL);
                }
            });
        });
    }
github dfahlander / Dexie.js / addons / Dexie.Syncable / src / PersistedContext.js View on Github external
save() {
      // Store this instance in the syncContext property of the node it belongs to.
      return Dexie.vip(() => {
        return node.save();
      });
    }
  }
github dfahlander / Dexie.js / addons / Dexie.Observable / src / Dexie.Observable.js View on Github external
function onLatestRevisionIncremented(dbname, latestRevision) {
        if (dbname === db.name) {
            if (handledRevision >= latestRevision) return; // Make sure to only run once per revision. (Workaround for IE triggering storage event on same window)
            handledRevision = latestRevision;
            Dexie.vip(function() {
                readChanges(latestRevision).catch('DatabaseClosedError', e=>{
                    // Handle database closed error gracefully while reading changes.
                    // Don't trigger unhandledrejection
                    // Even though we intercept the close() method, it might be called when in the middle of
                    // reading changes and then that flow will cancel with DatabaseClosedError.
                });
            });
        }
    }
github dfahlander / Dexie.js / addons / Dexie.Observable / src / Dexie.Observable.js View on Github external
function onLatestRevisionIncremented(dbname, latestRevision) {
        if (dbname === db.name) {
            if (handledRevision >= latestRevision) return; // Make sure to only run once per revision. (Workaround for IE triggering storage event on same window)
            handledRevision = latestRevision;
            Dexie.vip(function() {
                readChanges(latestRevision);
            });
        }
    }
github dfahlander / Dexie.js / addons / Dexie.Syncable / src / enqueue.js View on Github external
context.ongoingOperation = Dexie.ignoreTransaction(function () {
          return Dexie.vip(function () {
            return fn();
          });
        }).finally(()=> {
          delete context.ongoingOperation;