Skip to content

Interface: UseLocksResult

@roomful/react


@roomful/react / UseLocksResult

Defined in: react/src/index.ts:276

Describes the return value of useLocks.

acquire: (key, options?) => Promise<boolean>

Defined in: react/src/index.ts:286

Claims exclusive ownership of a key, resolving whether the local peer holds it.

Claims exclusive ownership of key. Broadcasts a claim, waits a short bounded window for any conflicting earlier claim to surface, then resolves to whether the local peer is the holder.

With options.timeout, keeps re-attempting until the lock frees (a holder releases or its TTL expires) or the timeout elapses. With options.ttl, the claim self-expires after the TTL so a crashed holder cannot hold it forever.

string

The lock key to claim.

LockAcquireOptions

Optional TTL and wait-timeout configuration.

Promise<boolean>

A promise resolving true when the local peer holds the lock, false when another peer holds it.


getHolder: (key) => Peer<PresenceData> | null

Defined in: react/src/index.ts:306

Returns the peer currently holding a key, or null.

Returns the peer currently holding key, or null when the lock is free.

string

The lock key to resolve.

Peer<PresenceData> | null

The holding peer, or null.


isLocked: (key) => boolean

Defined in: react/src/index.ts:301

Reports whether a key is currently held by any peer.

Reports whether key is currently held by any peer (including the local peer).

string

The lock key to test.

boolean

true when the key has a non-expired holder.


locks: LockState[]

Defined in: react/src/index.ts:280

Exposes the resolved state of every currently-held lock.


release: (key) => void

Defined in: react/src/index.ts:291

Releases a lock held by the local peer.

Releases a lock held by the local peer. No-op when the local peer does not hold key.

string

The lock key to release.

void

Nothing.


releaseAll: () => void

Defined in: react/src/index.ts:296

Releases every lock held by the local peer.

Releases every lock currently held by the local peer.

void

Nothing.