H5P Guides

H5P.EventDispatcher

Class H5P.EventDispatcher-EventDispatcher

Class Summary
Constructor AttributesConstructor Name and Description
<inner>  
The base of the event system.
Method Summary
Method AttributesMethod Name and Description
 
off(type, listener)
Remove event listener.
 
on(type, listener, thisArg)
Add new event listener.
 
once(type, listener, thisArg)
Add new event listener that will be fired only once.
 
trigger(event, eventData)
Dispatch event.
Class Detail
<inner> H5P.EventDispatcher-EventDispatcher()
The base of the event system. Inherit this class if you want your H5P to dispatch events.
Method Detail
off(type, listener)
Remove event listener. If no listener is specified, all listeners will be removed.
Parameters:
{String} type
- Event type
{Function} listener
- Event listener
Throws:
{TypeError}
listener - must be a function

on(type, listener, thisArg)
Add new event listener.
Parameters:
{String} type
- Event type
{Function} listener
- Event listener
{Function} thisArg
- Optionally specify the this value when calling listener.
Throws:
{TypeError}
listener - Must be a function

once(type, listener, thisArg)
Add new event listener that will be fired only once.
Parameters:
{String} type
- Event type
{Function} listener
- Event listener
{Function} thisArg
- Optionally specify the this value when calling listener.
Throws:
{TypeError}
listener - must be a function

trigger(event, eventData)
Dispatch event.
Parameters:
{String|Function} event
- Event object or event type as string
{mixed} eventData
Custom event data(used when event type as string is used as first argument