Skip to content

Commit

Permalink
fix(useWebNotification)!: should be exposed as EventHooksOn (#2821)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
Alfred-Skyblue and antfu committed Mar 4, 2023
1 parent 8f2a3c4 commit bcd2ada
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions packages/core/useWebNotification/index.ts
Expand Up @@ -82,7 +82,6 @@ export interface WebNotificationOptions {
}

export interface UseWebNotificationOptions extends WebNotificationOptions, ConfigurableWindow {

}

/**
Expand Down Expand Up @@ -114,10 +113,10 @@ export const useWebNotification = (
await Notification.requestPermission()
}

const onClick: EventHook = createEventHook<Event>()
const onShow: EventHook = createEventHook<Event>()
const onError: EventHook = createEventHook<Event>()
const onClose: EventHook = createEventHook<Event>()
const { on: onClick, trigger: clickTrigger }: EventHook = createEventHook<Event>()
const { on: onShow, trigger: showTrigger }: EventHook = createEventHook<Event>()
const { on: onError, trigger: errorTrigger }: EventHook = createEventHook<Event>()
const { on: onClose, trigger: closeTrigger }: EventHook = createEventHook<Event>()

// Show notification method:
const show = async (overrides?: WebNotificationOptions) => {
Expand All @@ -128,10 +127,11 @@ export const useWebNotification = (
const options = Object.assign({}, defaultOptions, overrides)
notification.value = new Notification(options.title || '', options)

notification.value.onclick = (event: Event) => onClick.trigger(event)
notification.value.onshow = (event: Event) => onShow.trigger(event)
notification.value.onerror = (event: Event) => onError.trigger(event)
notification.value.onclose = (event: Event) => onClose.trigger(event)
notification.value.onclick = clickTrigger
notification.value.onshow = showTrigger
notification.value.onerror = errorTrigger
notification.value.onclose = closeTrigger

return notification.value
}

Expand Down

0 comments on commit bcd2ada

Please sign in to comment.