function callListener()

in public/dexie.js [1120:1147]


  function callListener(cb, promise, listener) {
    try {
      // Set static variable currentFulfiller to the promise that is being fullfilled,
      // so that we connect the chain of promises (for long stacks support)
      currentFulfiller = promise;
      // Call callback and resolve our listener with it's return value.
      var ret,
        value = promise._value;
      if (promise._state) {
        // cb is onResolved
        ret = cb(value);
      } else {
        // cb is onRejected
        if (rejectingErrors.length) rejectingErrors = [];
        ret = cb(value);
        if (rejectingErrors.indexOf(value) === -1) markErrorAsHandled(promise); // Callback didnt do Promise.reject(err) nor reject(err) onto another promise.
      }
      listener.resolve(ret);
    } catch (e) {
      // Exception thrown in callback. Reject our listener.
      listener.reject(e);
    } finally {
      // Restore env and currentFulfiller.
      currentFulfiller = null;
      if (--numScheduledCalls === 0) finalizePhysicalTick();
      --listener.psd.ref || listener.psd.finalize();
    }
  }