Skip to content

Latest commit

 

History

History
65 lines (51 loc) · 1.93 KB

File metadata and controls

65 lines (51 loc) · 1.93 KB

LockRequestOptions

Namespace: SpawnDev.SpawnJS.JSObjects
Source: JSObjects/LockRequestOptions.cs
MDN Reference: LockRequestOptions on MDN

An object describing characteristics of the lock you want to create. https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request#options

Properties

Property Type Access Description
LockRequestOptions class get An object describing characteristics of the lock you want to create. https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request#options
IfAvailable bool? get
Steal bool? get
Signal AbortSignal? get

Examples

SpawnDev.SpawnJS Mapping Note: The JavaScript examples below show the standard Web API usage. In SpawnDev.SpawnJS, the same API is available with C# conventions:

  • Properties and methods use PascalCase (e.g., readyState becomes ReadyState)
  • Events use ActionEvent with +=/-= (e.g., addEventListener("click", fn) becomes OnClick += handler)
  • Async methods return Task<T> instead of Promise<T>
  • Objects should be disposed with using statements
  • Access via JS.Get<LockRequestOptions>(...) or constructor new LockRequestOptions(...)

General Example

await navigator.locks.request("my_resource", async (lock) => {
  // The lock was granted.
});

mode example

async function doRead() {
  await navigator.locks.request(
    "my_resource",
    { mode: "shared" },
    async (lock) => {
      // Read code here.
    },
  );
}

mode example

async function doWrite() {
  await navigator.locks.request(
    "my_resource",
    { mode: "exclusive" },
    async (lock) => {
      // Write code here.
    },
  );
}

See full example on MDN