Event<T>
Allows attaching handlers and broadcasting events.
Type Parameters
• T extends unknown
[]
Implements
Constructors
new Event()
new Event<T>(options?): Event<T>
Creates new event instance.
Parameters
• options?: EventOptions
Returns
Event
<T
>
Defined in
Accessors
last
Get Signature
get last(): undefined | [...T[]]
In case event was broadcast at least once, returns last payload; undefined otherwise.
Returns
undefined
| [...T[]
]
In case event was broadcast at least once, returns last payload; undefined otherwise.
Implementation of
Defined in
Methods
broadcast()
broadcast(...args): void
Notifies attached handlers with specified payload.
Parameters
• ...args: [...T[]
]
The payload of the notification.
Returns
void
Implementation of
Defined in
subscribe()
subscribe(handler): string
Attaches specified handler for events emitted by this event instance.
Parameters
• handler
The handler to attach.
Returns
string
Implementation of
Defined in
subscribeById()
subscribeById(id, handler): void
Attaches handler with specified identifier for events emitted by this event instance.
Parameters
• id: string
Identifier of the handler.
• handler
The handler to attach.
Returns
void
Defined in
unsubscribe()
unsubscribe(handler): void
Detaches specified handler from events emitted by this event instance.
Parameters
• handler
The handler to detach.
Returns
void
Implementation of
Defined in
unsubscribeById()
unsubscribeById(id): void
Detaches handler with specified identifier from events emitted by this event instance.
Parameters
• id: string
Identifier of the handler.
Returns
void