ee-event-emitter
Advanced tools
Comparing version 0.2.1 to 0.2.2
{ | ||
"name" : "ee-event-emitter" | ||
, "description" : "An EventEmitter implementation" | ||
, "version" : "0.2.1" | ||
, "description" : "A portable event emitter class" | ||
, "version" : "0.2.2" | ||
, "homepage" : "https://github.com/eventEmitter/ee-event-emitter" | ||
, "author" : "Michael van der Weg <michael@eventemitter.com> (http://eventemitter.com/)" | ||
, "author" : "Michael van der Weg <michael@eventemitter.com> (http://eventemitter.com/)" | ||
, "license" : "MIT" | ||
@@ -19,3 +19,3 @@ , "repository": { | ||
, "dependencies": { | ||
"ee-class" : "1.0.x" | ||
"ee-class" : "^1.2.x" | ||
, "ee-log" : "0.2.x" | ||
@@ -22,0 +22,0 @@ } |
@@ -1,20 +0,16 @@ | ||
# ee-events | ||
# ee-event-emitter | ||
## installation | ||
npm install ee-events | ||
A portable event emitter class | ||
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 = require('ee-event-emitter'); | ||
var eventEmitter = new EventEmitter(); | ||
// attach listener | ||
eventEmitter.on( "eventName", cb ); | ||
eventEmitter.on('eventName', cb); | ||
// attach listsner which is called once | ||
eventEmitter.once( "eventName", cb ); | ||
eventEmitter.once('eventName', cb); | ||
@@ -25,9 +21,9 @@ // remove all listeners for all events | ||
// remove listeners for specific event | ||
eventEmitter.off( "eventName" ); | ||
eventEmitter.off('eventName'); | ||
// remove a single listener | ||
eventEmitter.off( "eventName", listener ); | ||
eventEmitter.off('eventName', listener); | ||
// emit an event | ||
eventEmitter.emit( "eventName", arg, arg, .... ); | ||
eventEmitter.emit('eventName', arg, arg, ....); | ||
@@ -38,24 +34,24 @@ // get all listeners | ||
// get lsisteners for a specific event | ||
eventEmitter.listsner( "eventName" ); | ||
eventEmitter.listsner('eventName'); | ||
// event which is emitted when an event listener is added | ||
eventEmitter.on( "listener", function( eventName, listener ){} ); | ||
eventEmitter.on('listener', function(eventName, listener){}); | ||
// event which is emitted when an event listener is removed | ||
eventEmitter.on( "removeListener", function( eventName, listener ){} ); | ||
eventEmitter.on('removeListener', function(eventName, listener ){}); | ||
## usage | ||
## Examples | ||
var Class = require( "ee-class" ) | ||
, EventEmitter = require( "ee-event-emitter" ); | ||
var Class = require('ee-class') | ||
, EventEmitter = require('ee-event-emitter'); | ||
var Human = new Class( { | ||
inherits: EventEmitter | ||
, name: "" | ||
var Human = new Class({ | ||
ssinherits: EventEmitter | ||
, name: '' | ||
, age: 29 | ||
, init: function( options ){ | ||
, init: function(options) { | ||
this.name = options.name; | ||
@@ -65,34 +61,34 @@ } | ||
, 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" ); | ||
, 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 | ||
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!" ); } | ||
} | ||
} ); | ||
var dylan = new Boy({ | ||
name: 'Dylan' | ||
}); | ||
fabian.sayHello( "michael" ); // starting console output: | ||
// Hi my name is Fabian and i'm 12 years old. | ||
// finished console output! | ||
dylan.on('startHello', function() { | ||
console.log('starting console output:'); | ||
}); | ||
dylan.on('endHello', function() { | ||
console.log('finished console output:'); | ||
}); | ||
# Version History | ||
- 0.1.0: initial version | ||
dylan.sayHello('michael'); // starting console output: | ||
// Hi my name is Dylan and i'm 12 years old. | ||
// finished console output! |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8959
9
92
+ Addedee-class@1.4.0(transitive)
- Removedee-class@1.0.9(transitive)
Updatedee-class@^1.2.x