Vue hook to query permission status for browser APIs
Browser environment is required
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>
}
})
type PermissionDesc =
| PermissionDescriptor
| DevicePermissionDescriptor
| MidiPermissionDescriptor
| PushPermissionDescriptor
type State = PermissionState | ''
function usePermission(permissionDesc: PermissionDesc): Ref<State>