new EventDispatcher(emitter, memorizeopt)
FORGE.EventDispatcher can dispatch and reference listeners.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
emitter |
Object | The object that wiil be considered as the emitter of the event. | |
memorize |
boolean |
<optional> |
Does the dispatcher should memorize the previous dispatcher ? |
- Source:
Extends
Members
active :boolean
Get and set the active flag associated to this event dispatcher.
If active is false, this dispatcher will not dispatch any event.
If active is false, this dispatcher will not dispatch any event.
Type:
- boolean
- Source:
(readonly) alive :boolean
Get the alive flag value of the object.
Type:
- boolean
- Inherited From:
- Source:
(readonly) className :string
Get the class name of the object.
Type:
- string
- Inherited From:
- Source:
data :*
Get and set any custom data you want to associate to this object.
Type:
- *
- Inherited From:
- Source:
debug :boolean
Get and set the debug flag.
Type:
- boolean
- Inherited From:
- Source:
(readonly) emitter :Object
Get the emitter object associated to this event dispatcher.
Type:
- Object
- Source:
memorized :boolean
Get and set the memorize flag associated to this event dispatcher.
Type:
- boolean
- Source:
(readonly) onDestroy :FORGE.EventDispatcher
Get the onDestroy FORGE.EventDispatcher, this event is emitted at the end of the destroy sequence.
Type:
- Inherited From:
- Source:
(readonly) tags :Array
Get the tags associated to this object.
Type:
- Array
- Inherited From:
- Source:
(readonly) uid :string
Get the uid of the object.
Type:
- string
- Inherited From:
- Source:
warning :boolean
Get and set the warning flag.
Type:
- boolean
- Inherited From:
- Source:
Methods
add(listener, context, priorityopt)
Add an event listener function.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
listener |
function | Event handler callback function. | |
context |
Object | The context for the listener call. | |
priority |
number |
<optional> |
Priority level for the event to be execute. |
- Source:
addOnce(listener, context, priorityopt)
Add an event listener function that will be triggered only once.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
listener |
function | Event handler callback function. | |
context |
Object | The context for the listener call. | |
priority |
number |
<optional> |
Priority level for the event to be execute. |
- Source:
destroy()
Destroy method.
- Overrides:
- Source:
dispatch(dataopt, asyncopt)
Dispatch the event, will trigger all the listeners methods.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
data |
* |
<optional> |
Any object or data you want to associate with the dispatched event. |
async |
boolean |
<optional> |
Does the dispatch need to be async ? |
- Source:
has(listener, context) → {boolean}
Check if this event dispatcher has a specific listener.
Parameters:
Name | Type | Description |
---|---|---|
listener |
function | listener function to check. |
context |
Object | listener context to check. |
- Source:
Returns:
Returns true if the dispatcher has the listener, false if not.
- Type
- boolean
log(value)
Basic log method, log a string in the console if debug is enabled.
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value you want to log in the console. |
- Inherited From:
- Source:
remove(listener, context)
Remove a FORGE.Listener from this event dispatcher.
Parameters:
Name | Type | Description |
---|---|---|
listener |
function | The listener handler to be removed. |
context |
Object | The context of the handler to be removed. |
- Source:
warn(valuenullable)
Basic warn method, log a warn string in the console if warning is enabled.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
value |
string | Object |
<nullable> |
The value you want to warn in the console. |
- Inherited From:
- Source: