4 Matching Annotations
  1. Jun 2023
    1. ```js FastMutex.prototype.runInLock = function (callback, opt_context) { this._setX()

      if (!this._isLockAvailable()) { this._retry(callback, opt_context) return }

      this._setY()

      if (this._getX() != this._clientId) { window.setTimeout(function () { if (this.hasLock()) this._execute(callback, opt_context) else this._retry(callback, opt_context) }.bind(this), Math.round(Math.random() * 100))

      } else { this._execute(callback, opt_context) } }

      FastMutex.prototype._execute = function (callback, opt_context) { var rv try { rv = callback.call(opt_context) } finally { if (rv instanceof goog.async.Deferred) { rv.addFinally(this._clearLock, this) } else { this._clearLock() } } } ```

  2. Jul 2022
  3. Feb 2022
  4. Feb 2021
    1. try { const value = await localforage.getItem('somekey'); // This code runs once the value has been loaded // from the offline store. console.log(value); } catch (err) { // This code runs if there were any errors. console.log(err); }

      This looks like the best approach for me. async/await