Skip to content

JavaScript events for custom objects

License

Notifications You must be signed in to change notification settings

mrdoob/eventdispatcher.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eventdispatcher.js

JavaScript events for custom objects

Usage

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();

About

JavaScript events for custom objects

Resources

License

Stars

Watchers

Forks

Packages

No packages published