event.Manager
Extends IEventManager.
Event manager. Using an event manager, you can subscribe to and unsubscribe from events, as well as initiate the events themselves. The manager implements the possibility of building a hierarchy of event propagation using the method event.Manager.setParent.
Event propagation has three phases:
- 1. Direct subscribers get events.
- 2. Objects that are higher up in the hierarchy get events when they are relayed on the parent event manager.
- 3. Default action handlers get events via a type + 'defaultaction' service event; the default action is performed only if the event's "target" field matches the context for the event manager.
The manager also allows you to specify the priority when adding event handlers. When throwing events, the handlers will be called in order of decreasing priority.
Subscriptions with the same callback and context parameters but different priority settings are considered to be different. When removing subscriptions, you must specify the same priority as was set when it was added.
Constructor
event.Manager([params])
Parameters:
Parameter |
Default value |
Description |
— |
Type: Object Parameters of the event manager. |
|
— |
Type: Object The context object of the event manager. |
|
— |
Type: IEventWorkflowController[] Controller or controllers for the event manager. |
|
— |
Type: IEventManager Parent event manager. |
Methods
Name |
Returns |
Description |
Adds a new subscription. Inherited from IEventManager. |
||
Function that creates the event object. Called in the "fire" method when the passed object is not an instance of the Event class or its descendant. |
||
Fires an event. |
||
IEventManager|null |
Returns reference to the parent event manager. Inherited from IEventManager. |
|
group() |
Returns the group of event listeners associated with the given event manager. Inherited from IEventManager. |
|
Adds a listener, which calls the handler function only one time. Inherited from IEventManager. |
||
Removes an existing subscription. Inherited from IEventManager. |
||
Sets the parent event manager. |
Methods details
createEventObject
{Event} createEventObject(type, event, target)
Function that creates the event object. Called in the "fire" method when the passed object is not an instance of the Event class or its descendant.
Returns Event object.
Parameters:
Parameter |
Default value |
Description |
|
— |
Type: String Type of event. |
— |
Type: Object Object that describes the event. |
|
— |
Type: Object Object that the event occurred on. |
* Mandatory parameter/option.
fire
{event.Manager} fire(type[, event])
Fires an event.
Returns self-reference.
Parameters:
Parameter |
Default value |
Description |
|
— |
Type: String Type of event. |
— |
Type: Object|Event Event. If a hash with data is passed, the createEventObject method will be called for it and further actions will be performed with the newly created event. |
* Mandatory parameter/option.
setParent
{event.Manager} setParent(parent)
Sets the parent event manager.
Returns self-reference.
Parameters:
Parameter |
Default value |
Description |
— |
Type: IEventManager|null Parent event manager. |
* Mandatory parameter/option.
Mandatory parameter/option.