Documentation
Reference
2.1.55 (current version)
collection
interactivityModel
Interfaces

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:

ParameterDefault valueDescription
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

NameReturnsDescription
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.

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:

ParameterDefault valueDescription
type*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: String

Type of event.

event*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Object

Object that describes the event.

target*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Object

Object that the event occurred on.

* Mandatory parameter/option.

fire

Fires an event.

Returns self-reference.

Parameters:

ParameterDefault valueDescription
type*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

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.

once

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

Returns self-reference.

Parameters:

ParameterDefault valueDescription
types*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: String[][]|String[]

Type or array of types for the event.

callback*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Function

Handler function for the event. The function is passed an object of the event IEvent.

context

Type: Object

Context for the handler.

priority 0

Type: Integer

Subscription priority.

* Mandatory parameter/option.

setParent

{event.Manager} setParent(parent)

Sets the parent event manager.

Returns self-reference.

Parameters:

ParameterDefault valueDescription
parent*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: IEventManager|null

Parent event manager.

* Mandatory parameter/option.