Skip to content

Magic Emitter

Package
@maas/vue-equipment/plugins
Last Changed
last week

A simple wrapper around mitt, to listen to all Vue Equipment events.

Demo

Usage

js
import {
  useMagicEmitter,
  type MagicEmitterEvents,
} from '@maas/vue-equipment/plugins'
import { type ValueOf } from '@maas/vue-equipment/utils'

function callback(
  id: keyof MagicEmitterEvents,
  payload: ValueOf<MagicEmitterEvents>
) {
  console.log(id, payload)
}

useMagicEmitter().on('*', callback)

onBeforeUnmount(() => {
  useMagicEmitter().off('*', callback)
})

Released under the MIT License.