npm.io
0.1.0 • Published 11 years ago

eventtarget

Licence
MIT
Version
0.1.0
Deps
0
Vulns
0
Weekly
0
Stars
4

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>

Keywords