@serenity-is/sleekgrid / EventEmitter
Class: EventEmitter<TArgs, TEventData>
A simple publisher-subscriber implementation.
Type parameters
Name | Type |
---|---|
TArgs |
any |
TEventData |
extends IEventData = IEventData |
Table of contents
Constructors
Methods
Constructors
constructor
• new EventEmitter<TArgs
, TEventData
>(): EventEmitter
<TArgs
, TEventData
>
Type parameters
Name | Type |
---|---|
TArgs |
any |
TEventData |
extends IEventData = IEventData |
Returns
EventEmitter
<TArgs
, TEventData
>
Methods
clear
▸ clear(): void
Returns
void
Defined in
notify
▸ notify(args?
, e?
, scope?
): any
Fires an event notifying all subscribers.
Parameters
Name | Type | Description |
---|---|---|
args? |
any |
Additional data object to be passed to all handlers. |
e? |
TEventData |
Optional. An EventData object to be passed to all handlers. For DOM events, an existing W3C/jQuery event object can be passed in. |
scope? |
object |
Optional. The scope ("this") within which the handler will be executed. If not specified, the scope will be set to the Event instance. |
Returns
any
Defined in
subscribe
▸ subscribe(fn
): void
Adds an event handler to be called when the event is fired.
Event handler will receive two arguments - an EventData
and the data
object the event was fired with.
Parameters
Name | Type | Description |
---|---|---|
fn |
(e : TEventData , args : TArgs ) => void |
Event handler. |
Returns
void
Method
subscribe
Defined in
unsubscribe
▸ unsubscribe(fn
): void
Removes an event handler added with subscribe(fn)
.
Parameters
Name | Type | Description |
---|---|---|
fn |
(e : TEventData , args : TArgs ) => void |
Event handler to be removed. |
Returns
void
Method
unsubscribe