eventtarget
v0.1.0
Published
W3C JavaScript events for custom objects
Downloads
8,472
Readme
eventtarget.js
JavaScript events for custom objects
Usage
<script src="EventTarget.js"></script>
<script>
// Applying EventTarget to custom object
var Car = function () {
EventTarget.call( this );
this.start = function () {
this.dispatchEvent( { type: 'started', foo: 'bar' } );
};
};
// Using events
var car = new Car();
car.addEventListener( 'started', function ( event ) {
alert( 'vroom vroom!' );
} );
car.start();
</script>