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 | Methods

Constructor

event.Manager([params])

Parameters:

Parameter

Default value

Description

params

Type: Object

Parameters of the event manager.

params.context

Type: Object

The context object of the event manager.

params.controllers

Type: IEventWorkflowController[]

Controller or controllers for the event manager.

params.parent

Type: IEventManager

Parent event manager.

Methods

Name

Returns

Description

add(types, callback[, context[, priority]])

IEventManager

Adds a new subscription.

Inherited from IEventManager.

createEventObject(type, event, target)

Event

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.

fire(type[, event])

event.Manager

Fires an event.

getParent()

IEventManager|null

Returns reference to the parent event manager.

Inherited from IEventManager.

group()

IEventGroup

Returns the group of event listeners associated with the given event manager.

Inherited from IEventManager.

once(types, callback[, context[, priority]])

IEventManager

Adds a listener, which calls the handler function only one time.

Inherited from IEventManager.

remove(types, callback[, context[, priority]])

IEventManager

Removes an existing subscription.

Inherited from IEventManager.

setParent(parent)

event.Manager

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*

Type: String

Type of event.

event*

Type: Object

Object that describes the event.

target*

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*

Type: String

Type of event.

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

parent*

Type: IEventManager|null

Parent event manager.

* Mandatory parameter/option.