Natural Preference for Minification

    This package has been deprecated

    Author message:

    small-eventemitter has been renamed to tiny-events

    small-eventemitter

    1.0.1 • Public • Published

    small-eventemitter Build Status

    A very small (400b) EventEmitter implementation for client- and server-side code.

    installation

    npm install --save small-eventemitter

    usage

    instantiate the object directly..

    // import the module
    var EventEmitter = require('small-eventemitter').EventEmitter;
    
    // instantiate the object
    var events = new EventEmitter();
    
    // listen to 'foo' events
    events.on('foo', function (data) {
        console.log('foo occured!');
    });
    
    // emit a 'foo' event
    events.emit('foo');
    
    // emit a 'foo' event with some data
    events.emit('foo', 'hello world');
    
    // remove all foo event listeners
    events.off('foo');

    ... or subclass it.

    var utils = require('utils');
    var EventEmitter = require('small-eventemitter').EventEmitter;
    
    function MyClass() {
        EventEmitter.call(this);
    }
    
    util.inherits(MyClass, EventEmitter);

    API

    • on(type: string, listener: Function): EventEmitter
    • once(type: string, listener: Function): EventEmitter
    • off(type: string, listener?: Function): EventEmitter
    • emit(type: string, ...args: any[]): EventEmitter

    Install

    npm i small-eventemitter

    DownloadsWeekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • zaubernerd