Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rosylilly/eventemitter.js

To grant all object event function
https://github.com/rosylilly/eventemitter.js

Last synced: 5 days ago
JSON representation

To grant all object event function

Awesome Lists containing this project

README

        

# EventEmitter.js

var object = {};
EventEmitter.extends(object);

object.addEventListener("sampleEvent", function(e){
alert(e); // => "sampleEvent"
});
object.emit("sampleEvent");

function C(){};
C.prototype = new EventEmitter();
var cObject = new C();
cObject.addEventListener("sampleEvent", function(e, arg){
alert(arg) // => "Foo!!"
});
cObject.emit("sampleEvent", "Foo!!!");