localstorage-lock
Generic localstorage lock implementation
API
runWithLock
Run a specified code block with a localstorage lock
runWithLock(<localstorage key>, <fn to run>, <options>);
Options:
{
timeout: 1000,
lockWriteTime: 50,
checkTime: 10,
retry: true
}
####Example Use
runWithLock('lock.some-key', () => {
const someKey = localStorage.getItem('some-key');
console.log(someKey)
localStorage.removeItem('some-key')
}, { timeout: 500 });
tryRunWithLock
Wrapper function for tryWithLock
with option retry: false