<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>
forked from mrdoob/eventdispatcher.js
-
Notifications
You must be signed in to change notification settings - Fork 1
W3C JavaScript events for custom objects
License
piranna/EventTarget.js
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
W3C JavaScript events for custom objects
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published
Languages
- JavaScript 100.0%