handleWakeLock
Category Browser
Provides a way to prevent devices from dimming or locking the screen when an application needs to keep running.
You may read more about the Screen Wake Lock API.
Demo
Your browser doesn't support the Screen Wake Lock API :(
Usage
IMPORTANT
Since it uses $effect
internally, you must either call handleWakeLock
in
the component initialization lifecycle or call it inside $effect.root
.
Type definitions
import { type ConfigurableDocument, type ConfigurableNavigator } from '../../__internal__/configurable.js';
import type { AutoCleanup, CleanupFunction } from '../../__internal__/types.js';
type WakeLockType = 'screen';
interface WakeLockSentinel extends EventTarget {
type: WakeLockType;
released: boolean;
release: () => Promise<void>;
}
interface HandleWakeLockOptions extends ConfigurableNavigator, ConfigurableDocument, AutoCleanup {
}
type HandleWakeLockReturn = {
readonly isSupported: boolean | undefined;
readonly isActive: boolean;
sentinel: WakeLockSentinel | null;
request: (type: WakeLockType) => Promise<void>;
forceRequest: (type: WakeLockType) => Promise<void>;
release: () => Promise<void>;
cleanup: CleanupFunction;
};
/**
* Provides a way to prevent devices from dimming or locking the screen when an application needs to keep running.
* @param options Additional options to customize the behavior.
*/
export declare function handleWakeLock(options?: HandleWakeLockOptions): HandleWakeLockReturn;
export {};