useWakeLock
Reactive Screen Wake Lock API provides a way to prevent devices from dimming or locking the screen when an application needs to keep running.
Demo
Usage
import { useWakeLock } from '@vueuse/core'
const { isSupported, isActive, request, release } = useWakeLock()
import { useWakeLock } from '@vueuse/core'
const { isSupported, isActive, request, release } = useWakeLock()
If isActive
is called, isActive
will be true, and if release
is called, or other tab is displayed, or the window is minimized,isActive
will be false.
Type Declarations
declare type WakeLockType = "screen"
export interface WakeLockSentinel extends EventTarget {
type: WakeLockType
released: boolean
release: () => Promise<void>
}
/**
* Reactive Screen Wake Lock API.
*
* @see https://vueuse.org/useWakeLock
* @param options
*/
export declare const useWakeLock: (
options?: ConfigurableNavigator & ConfigurableDocument
) => {
isSupported: boolean | undefined
isActive: Ref<boolean>
request: (type: WakeLockType) => Promise<void>
release: () => Promise<void>
}
export declare type UseWakeLockReturn = ReturnType<typeof useWakeLock>
declare type WakeLockType = "screen"
export interface WakeLockSentinel extends EventTarget {
type: WakeLockType
released: boolean
release: () => Promise<void>
}
/**
* Reactive Screen Wake Lock API.
*
* @see https://vueuse.org/useWakeLock
* @param options
*/
export declare const useWakeLock: (
options?: ConfigurableNavigator & ConfigurableDocument
) => {
isSupported: boolean | undefined
isActive: Ref<boolean>
request: (type: WakeLockType) => Promise<void>
release: () => Promise<void>
}
export declare type UseWakeLockReturn = ReturnType<typeof useWakeLock>
Source
Contributors
Anthony Fu
wheat
koheing