Class: DispatcherImpl
@ima/core.DispatcherImpl
Default implementation of the Dispatcher interface.
Hierarchy
↳
DispatcherImpl
Constructors
constructor
• new DispatcherImpl()
Initializes the dispatcher.
Overrides
Defined in
packages/core/src/event/DispatcherImpl.ts:32
Properties
_eventListeners
• Protected
_eventListeners: Map
<string
, Map
<DispatcherListener
<any
>, Set
<unknown
>>>
Defined in
packages/core/src/event/DispatcherImpl.ts:22
$dependencies
▪ Static
$dependencies: Dependencies
= []
Defined in
packages/core/src/event/DispatcherImpl.ts:27
Methods
_createNewEvent
▸ _createNewEvent(event
): void
Create new Map storage of listeners for the specified event.
Parameters
Name | Type | Description |
---|---|---|
event | string | The name of the event. |
Returns
void
Defined in
packages/core/src/event/DispatcherImpl.ts:153
_createNewListener
▸ _createNewListener<L
>(event
, listener
): void
Create new Set storage of scopes for the specified event and listener.
Type parameters
Name | Type |
---|---|
L | extends DispatcherListener <any > |
Parameters
Name | Type | Description |
---|---|---|
event | string | The name of the event. |
listener | L | The event listener. |
Returns
void
Defined in
packages/core/src/event/DispatcherImpl.ts:164
_getListenersOf
▸ _getListenersOf(event
): Readonly
<Map
<DispatcherListener
<any
>, Set
<unknown
>>>
Retrieves the map of event listeners to scopes they are bound to.
Parameters
Name | Type | Description |
---|---|---|
event | string | The name of the event. |
Returns
Readonly
<Map
<DispatcherListener
<any
>, Set
<unknown
>>>
A map of event listeners to the scopes in which they should be executed. The returned map is an unmodifiable empty map if no listeners are registered for the event.
Defined in
packages/core/src/event/DispatcherImpl.ts:209
_getScopesOf
▸ _getScopesOf<L
>(event
, listener
): Readonly
<Set
<unknown
>>
Retrieves the scopes in which the specified event listener should be executed for the specified event.
Type parameters
Name | Type |
---|---|
L | extends DispatcherListener <any > |
Parameters
Name | Type | Description |
---|---|---|
event | string | The name of the event. |
listener | L | The event listener. |
Returns
Readonly
<Set
<unknown
>>
The scopes in which the specified listeners should be executed in case of the specified event. The returned set is an unmodifiable empty set if no listeners are registered for the event.
Defined in
packages/core/src/event/DispatcherImpl.ts:187
clear
▸ clear(): DispatcherImpl
Deregisters all event listeners currently registered with this dispatcher.
Returns
Overrides
Defined in
packages/core/src/event/DispatcherImpl.ts:46
fire
▸ fire(event
, data
, imaInternalEvent?
): DispatcherImpl
Fires a new event of the specified name, carrying the provided data.
The method will synchronously execute all event listeners registered for the specified event, passing the provided data to them as the first argument.
Note that this method does not prevent the event listeners to modify the data in any way. The order in which the event listeners will be executed is unspecified and should not be relied upon.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
event | string | undefined | The name of the event to fire. |
data | any | undefined | The data to pass to the event listeners. |
imaInternalEvent | boolean | false | The flag signalling whether this is an internal IMA event. The fired event is treated as a custom application event if this flag is not set. The flag is used only for debugging and has no effect on the propagation of the event. |
Returns
This dispatcher.
Overrides
Defined in
packages/core/src/event/DispatcherImpl.ts:126
listen
▸ listen(event
, listener
, scope?
): DispatcherImpl
Registers the provided event listener to be executed when the specified event is fired on this dispatcher.
When the specified event is fired, the event listener will be executed with the data passed with the event as the first argument.
The order in which the event listeners will be executed is unspecified and should not be relied upon. Registering the same listener for the same event and with the same scope multiple times has no effect.
Parameters
Name | Type | Description |
---|---|---|
event | string | The name of the event to listen for. |
listener | DispatcherListener <any > | The event listener to register. |
scope? | unknown | The object to which the this keyword will be bound in the event listener. |
Returns
This dispatcher.
Overrides
Defined in
packages/core/src/event/DispatcherImpl.ts:55
unlisten
▸ unlisten(event
, listener
, scope?
): DispatcherImpl
Deregisters the provided event listener, so it will no longer be executed with the specified scope when the specified event is fired.
Parameters
Name | Type | Description |
---|---|---|
event | string | The name of the event for which the listener should be deregistered. |
listener | DispatcherListener <any > | The event listener to deregister. |
scope? | unknown | The object to which the this keyword would be bound in the event listener. |
Returns
This dispatcher.