Namespace: SpawnDev.SpawnJS.JSObjects
Inherits: SpawnJSObject
Source: JSObjects/WakeLock.cs
MDN Reference: WakeLock on MDN
The WakeLock interface of the Screen Wake Lock API can be used to request a lock that prevents device screens from dimming or locking when an application needs to keep running. https://developer.mozilla.org/en-US/docs/Web/API/WakeLock
| Signature | Description |
|---|---|
WakeLock(SpawnJSObjectReference _ref) |
Deserialization constructor |
| Method | Return Type | Description |
|---|---|---|
Request(string type) |
Task<WakeLockSentinel> |
Returns a Promise that fulfills with a WakeLockSentinel object if the screen wake lock is granted. |
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.,
readyStatebecomesReadyState)- Events use ActionEvent with
+=/-=(e.g.,addEventListener("click", fn)becomesOnClick += handler)- Async methods return
Task<T>instead ofPromise<T>- Objects should be disposed with
usingstatements- Access via
JS.Get<WakeLock>(...)or constructornew WakeLock(...)
try {
const wakeLock = await navigator.wakeLock.request("screen");
} catch (err) {
// the wake lock request fails - usually system related, such being low on battery
console.log(`${err.name}, ${err.message}`);
}