<script src="EventDispatcher.js"></script>
<script>
// Adding events to custom object
var Car = function () {
this.start = function () {
this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } );
};
};
Object.assign( Car.prototype, EventDispatcher.prototype );
// Using events
var car = new Car();
car.addEventListener( 'start', function ( event ) {
alert( event.message );
} );
car.start();
</script>
forked from mrdoob/eventdispatcher.js
-
Notifications
You must be signed in to change notification settings - Fork 0
JavaScript events for custom objects
License
NEXOES/nx-eventdispatcher-js
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
JavaScript events for custom objects
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published
Languages
- JavaScript 100.0%