Socket
Socket
Sign inDemoInstall

ee-event-emitter

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ee-event-emitter

A portable event emitter class


Version published
Weekly downloads
45
decreased by-19.64%
Maintainers
1
Weekly downloads
 
Created
Source

ee-event-emitter

A portable event emitter class

API

var EventEmitter = require('ee-event-emitter');
var eventEmitter = new EventEmitter();

// attach listener
eventEmitter.on('eventName', cb);

// attach listsner which is called once
eventEmitter.once('eventName', cb);

// remove all listeners for all events
eventEmitter.off();

// remove listeners for specific event
eventEmitter.off('eventName');

// remove a single listener
eventEmitter.off('eventName', listener);

// emit an event
eventEmitter.emit('eventName', arg, arg, ....);

// get all listeners
eventEmitter.listener();

// get lsisteners for a specific event
eventEmitter.listsner('eventName');

// event which is emitted when an event listener is added
eventEmitter.on('listener', function(eventName, listener){});

// event which is emitted when an event listener is removed
eventEmitter.on('removeListener', function(eventName, listener ){});

Examples

var   Class     		= require('ee-class')
	, EventEmitter    	= require('ee-event-emitter');


var Human = new Class({
      ssinherits: EventEmitter
    , name: ''
    , age: 29

    , init: function(options) {
        this.name = options.name;
    }


    , sayHello: function(to) {
        this.emit('startHello');
        console.log('Hi %s, my name is %s, i'm %s years old.', to, this.name, this.age);
        this.emit('endHello');
    }
});



var Boy = new Class({
      inherits: Human
    , age: 12
});


var dylan = new Boy({
    name: 'Dylan'
});


dylan.on('startHello', function() {
	console.log('starting console output:');
});


dylan.on('endHello', function() {
	console.log('finished console output:');
});


dylan.sayHello('michael');  // starting console output:
                            // Hi my name is Dylan and i'm 12 years old.
                      		// finished console output!

Keywords

FAQs

Package last updated on 10 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc