Function useLock

  • Promise-based lock implementation.

    When someone tries to acquire a lock using acquire they receive a promise for a release callback that is fulfilled as soon as previous lock owner invokes their release callback. If acquire is called after unmount then the returned promise is never fulfilled.

    Returns [isLocked: boolean, acquire: (() => Promise<(() => void)>)]