import { EventDispatcher } from 'EventDispatcher.js';
// Adding events to custom object
class Car extends EventDispatcher {
start() {
this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } );
}
}
// Using events
const car = new Car();
car.addEventListener( 'start', function ( event ) {
alert( event.message );
} );
car.start();
-
Notifications
You must be signed in to change notification settings - Fork 80
JavaScript events for custom objects
License
mrdoob/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