0.0.4 • Published 2 years ago

@nomorejalapenos/notifier v0.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago
import { createNotifier } from '@nomorejalapenos/notifier'

interface Events {
  enter: (data: string) => void
  leave: (data: string) => void
}

const notifier = createNotifier<Events>()

notifier.listen('enter', (data) => console.log(data))
notifier.listen('leave', handleLeave)
function handleLeave(data: string) {
  console.log(data)
}

notifier.notify('enter', 'some data')
notifier.notify('leave', 'some data')

notifier.unlisten('enter')
notifier.unlisten('leave', handleLeave)
notifier.unlistenAll()