- Jun 2023
-
medium.engineering medium.engineering
-
```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() } } } ```
-
- Jul 2022
-
chowdera.com chowdera.com
Tags
Annotators
URL
-
- Feb 2022
-
localforage.github.io localforage.github.io
Tags
Annotators
URL
-
- Feb 2021
-
github.com github.com
-
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
-