@yesstudio/nuxt-composables
    Preparing search index...

    Function useEventHook

    • Provides an event hook for subscribing to and triggering events.

      Type Parameters

      • T

        The type of the parameter that event callbacks receive.

      Returns UseEventHook<T>

      An object with methods to subscribe to, unsubscribe from, and trigger the event.

      const hook = useEventHook<string>()

      hook.on((message) => {
      console.log('Event received:', message)
      })

      hook.trigger('Hello, world!')

      hook.off()