smitter

A small event emitter

Usage no npm install needed!

<script type="module">
  import smitter from 'https://cdn.skypack.dev/smitter';
</script>

README

smitter

smitter is a small 250 byte event emitter.

Installation

npm i smitter

Usage

import smitter from 'smitter'

// create an instance
let emitter = smitter()

// subscribe to an event called 'hi'
let off = emitter.on('hi', x => {
  console.log(`hi ${x}!`)
})

// fire an event called 'hi' and pass data to the handler
emitter.emit('hi', 'mom') // 'hi mom!' logged to console

// remove subscription
off()

emitter.emit('hi', 'dad') // nothing

License

MIT License © Self Aware