tinymce.util.EventDispatcher
This class lets you add/remove and dispatch events by name on the specified scope. This makes it easy to add event listener logic to any class.
Examples
const eventDispatcher = new EventDispatcher();
eventDispatcher.on('click', () => console.log('data'));
eventDispatcher.dispatch('click', { data: 123 });
Summary
Methods
Name | Summary | Defined by |
---|---|---|
Dispatches the specified event by name. |
||
Fires the specified event by name. Deprecated in TinyMCE 6.0 and has been marked for removal in TinyMCE 7.0. Use |
||
Returns true/false if the dispatcher has a event of the specified name. |
||
Returns true/false if the specified event name is a native browser event or not. |
||
Unbinds an event listener to a specific event by name. |
||
Binds an event listener to a specific event by name. |
||
Binds an event listener to a specific event by name and automatically unbind the event once the callback fires. |
Methods
fire()
fire(name: String, args: Object?): Object
Fires the specified event by name.
Deprecated in TinyMCE 6.0 and has been marked for removal in TinyMCE 7.0. Use dispatch
instead.
has()
has(name: String): Boolean
Returns true/false if the dispatcher has a event of the specified name.
isNative()
isNative(name: String): Boolean
Returns true/false if the specified event name is a native browser event or not.
off()
off(name: String?, callback: Function?): Object
Unbinds an event listener to a specific event by name.
on()
on(name: String, callback: Function, prepend: Boolean): Object
Binds an event listener to a specific event by name.
once()
once(name: String, callback: Function, prepend: Boolean): Object
Binds an event listener to a specific event by name and automatically unbind the event once the callback fires.