Entegre has builtin support for user-defined non-DOM events. The event handler is E.events.


Method Parameters Returns Description Example
register name this Create container for name event if does not already exist register('myevent')
listen name, callback this Add a callback handler for name event listen('myevent',function(d) { console.log( d ); })
trigger name, [data] this Trigger name event trigger('myevent')ortrigger('myevent','Hi!')
events array Return array of all registered events events()

Calling register manually is not required, as both listen and trigger will create the event container if needed.

trigger supports passing of a single data argument, so use an object literal ({}) or array ([]) if you want to pass multiple variables to the callback.

Example of simple event usage

Create a simple handler to output any parameter data to the console for the event:

E.events.listen( 'myevent', function( d ) {
	console.log( d );
} );

Then, trigger the event:

E.events.trigger( 'myevent', 'Hello World!' );

You will see this in the console:

Hello World!
Last modified: 2016-02-07