Skip to content

piranna/EventTarget.js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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>

About

W3C JavaScript events for custom objects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%