0.1.7 • Published 3 years ago

@utsubo/events v0.1.7

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@utsubo/events

Minimalist library to emit and receive custom events.

yarn add @utsubo/events

Example

import { onEvent, offEvent, emitEvent, useEvent } from '@utsubo/events'

// Create an event listener
const handler = (e) => console.log('event', e)
onEvent('event', handler, { once: false })

// Dispatch a payload to event listeners
emitEvent('event', 'event data')

// Remove the event listener
offEvent('event', handler, { once: false })

// React hook bindings to create reactive handlers.
function Component() {
  useEvent('event', (e) => console.log('event', e), [key], { once: false })
}
0.1.7

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago