Pacote
    Preparing search index...

    Module @pacote/emitter

    @pacote/emitter

    version minified minified + gzip

    Minimalistic event emitter.

    yarn add @pacote/emitter
    
    import { createEmitter } from '@pacote/emitter'

    const emitter = createEmitter()

    emitter.on('greet', () => console.log('Hello, world!'))
    emitter.emit('greet') // => 'Hello, world!'

    createEmitter() creates a new instance of an event emitter that provides the following methods:

    Binds the fn callback to an event with the supplied name.

    The method returns a function that unbinds the callback, preventing it from being called again.

    const emitter = createEmitter()

    const unbind = emitter.on('greet', () => console.log('Hello, world!'))

    emitter.emit('greet') // triggers the callback

    unbind()

    emitter.emit('greet') // no longer triggers the callback

    Fires the named event, triggering any subscribers previously bound to it using the .on() method. Arguments provided after the name are passed to the callback function.

    const emitter = createEmitter()

    emitter.on('greet', (name) => console.log(`Hello, ${name}!`))

    emitter.emit('greet', 'TypeScript') // => 'Hello, TypeScript!'

    MIT © Luís Rodrigues.

    Functions

    createEmitter