Skip to content

⬅️ Back to Table of Contents

πŸ“„ usePermission

πŸ“Š Analysis Summary

Metric Count
πŸ”§ Functions 2
πŸ“¦ Imports 9
πŸ“ Interfaces 2
πŸ“‘ Type Aliases 3

πŸ“š Table of Contents

πŸ› οΈ File Location:

πŸ“‚ packages/core/usePermission/index.ts

πŸ“¦ Imports

Name Source
ShallowRef vue
ConfigurableNavigator ../_configurable
Supportable ../types
createSingletonPromise @vueuse/shared
shallowRef vue
toRaw vue
defaultNavigator ../_configurable
useEventListener ../useEventListener
useSupported ../useSupported

Functions

usePermission(permissionDesc: GeneralPermissionDescriptor | GeneralPe…, options: UsePermissionOptions<false>): UsePermissionReturn

Reactive Permissions API.

See: https://vueuse.org/usePermission

Tags: @__NO_SIDE_EFFECTS__

Raw JSDoc
/**
 * Reactive Permissions API.
 *
 * @see https://vueuse.org/usePermission
 *
 * @__NO_SIDE_EFFECTS__
 */
Code
export function usePermission(
  permissionDesc: GeneralPermissionDescriptor | GeneralPermissionDescriptor['name'],
  options?: UsePermissionOptions<false>,
): UsePermissionReturn

Internal helpers

Declared inside another function in this file.

update(): void

Returns: void

Code
() => {
    state.value = permissionStatus.value?.state ?? 'prompt'
  }

Interfaces

UsePermissionOptions<Controls extends boolean>

Interface Code
export interface UsePermissionOptions<Controls extends boolean> extends ConfigurableNavigator {
  /**
   * Expose more controls
   *
   * @default false
   */
  controls?: Controls
}

Properties

Name Type Optional Description
controls Controls βœ“ not shown

UsePermissionReturnWithControls

Interface Code
export interface UsePermissionReturnWithControls extends Supportable {
  state: UsePermissionReturn
  query: () => Promise<PermissionStatus | undefined>
}

Properties

Name Type Optional Description
state UsePermissionReturn βœ— not shown
query () => Promise<PermissionStatus \| undefined> βœ— not shown

Type Aliases

DescriptorNamePolyfill

type DescriptorNamePolyfill = 'accelerometer'
    | 'accessibility-events'
    | 'ambient-light-sensor'
    | 'background-sync'
    | 'camera'
    | 'clipboard-read'
    | 'clipboard-write'
    | 'gyroscope'
    | 'magnetometer'
    | 'microphone'
    | 'notifications'
    | 'payment-handler'
    | 'persistent-storage'
    | 'push'
    | 'speaker'
    | 'local-fonts';

GeneralPermissionDescriptor

type GeneralPermissionDescriptor = | PermissionDescriptor
    | { name: DescriptorNamePolyfill };

UsePermissionReturn

type UsePermissionReturn = Readonly<ShallowRef<PermissionState | undefined>>;

Generated by Syntax Scribe