Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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

An EventEmitter implementation

  • 0.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
27
decreased by-25%
Maintainers
1
Weekly downloads
 
Created
Source

ee-events

installation

npm install ee-events

if an «error» event is emitted and there is no listenr for the error event a stacktrace is printed and the application exits.

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 ){} );

usage

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


var Human = new Class( {
    inherits: 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 fabian = new Boy( { 
    name: "Fabian" 
    , on: {
          startHello: function(){ console.log( "starting console output:" ); }
        , endHello: function(){ console.log( "finished console output!" ); }
    }
} );


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

Version History

  • 0.1.0: initial version

Keywords

FAQs

Package last updated on 06 May 2014

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