8000 GitHub - aermin/web-locks at 0.3.2
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

aermin/web-locks

Repository files navigation

web-locks polyfill

push workflow release workflow npm license

a Web Locks API polyfill, work for the browsers which haven't support web lock API: navigator.lock, e.g. Firefox, Safari, IE.

Usage:

install this lib

npm i navigator.locks

import this lib and use it follow Web Locks API

import "navigator.locks";

navigator.locks.request("my_resource", async (lock) => {
  // The lock has been acquired.
  await do_something();
  await do_something_else();
  // Now the lock will be released.
});
// if you use Typescript, could import these types to use
import type {
  LockManager,
  Lock,
  LockInfo,
  LockManagerSnapshot,
  LocksInfo,
} from "navigator.locks";

Online demo

demo link

you could open this URL in two tabs, operate the lock buttons and see the page and console

Process

API ✅

  • navigator.locks.request

  • navigator.locks.request options:

    mode | ifAvailable | steal | signal

  • navigator.locks.query

CI/CD ✅

Unit test ✅

Packages

No packages published

Contributors 3

  •  
  •  
  •  
0