Skip to content

Latest commit

 

History

History
39 lines (29 loc) · 825 Bytes

File metadata and controls

39 lines (29 loc) · 825 Bytes

useTitle

Vue hook to query permission status for browser APIs

Browser environment is required

MDN Permissions Api

Usage

import { createComponent } from '@vue/composition-api'
import { useTitle } from 'vuses'

const Demo = createComponent({
  setup() {
    const permission = usePermission({ name: 'microphone' })
    return { permission }
  },
  render() {
    const { permission } = this
    return <div>{JSON.stringify(permission, null, 2)}</div>
  }
})

Reference

type PermissionDesc =
  | PermissionDescriptor
  | DevicePermissionDescriptor
  | MidiPermissionDescriptor
  | PushPermissionDescriptor

type State = PermissionState | ''

function usePermission(permissionDesc: PermissionDesc): Ref<State>