0.0.2 • Published 10 years ago

eventdispatcher.js v0.0.2

Weekly downloads
3
License
-
Repository
github
Last release
10 years ago

eventdispatcher.js

JavaScript events for custom objects

Usage

<script src="EventDispatcher.js"></script>
<script>

	// Adding events to custom object

	var Car = function () {

		this.start = function () {

			this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } );

		};

	};

	Car.prototype = Object.create( EventDispatcher.prototype );


	// Using events

	var car = new Car();

	car.addEventListener( 'start', function ( event ) {

		alert( event.message );

	} );

	car.start();

</script>