Documentation / base / Observable
Class: Observable<X>
Defined in: libs/base/src/event.ts:92
Observable event emitter implementation.
Provides subscription, one-time subscription, unsubscription, and synchronous dispatch for events defined by an EventMap.
Extended by
Type Parameters
X
X extends EventMap
The event map describing event names and payload tuples
Implements
IEventTarget<X>
Constructors
Constructor
new Observable<
X>():Observable<X>
Defined in: libs/base/src/event.ts:98
Creates an Observable.
Returns
Observable<X>
Methods
on()
on<
K>(type,listener,context?):void
Defined in: libs/base/src/event.ts:104
Sets up a function that will be called whenever the specified event is delivered to the target
Type Parameters
K
K extends string | number | symbol
Parameters
type
K
The event type to listen for
listener
EventListener<X, K>
The callback function
context?
unknown
Context object of the listener function
Returns
void
Implementation of
once()
once<
K>(type,listener,context?):void
Defined in: libs/base/src/event.ts:117
Sets up a function that will be called only once when the specified event is delivered to the target
Type Parameters
K
K extends string | number | symbol
Parameters
type
K
The event type to listen for
listener
EventListener<X, K>
The callback function
context?
unknown
Context object of the listener function
Returns
void
Implementation of
off()
off<
K>(type,listener?,context?):void
Defined in: libs/base/src/event.ts:130
Removes an event listener function previously registered.
Type Parameters
K
K extends string | number | symbol
Parameters
type
K
The event type for which to remove an event listener
listener?
The callback function to be removed
context?
unknown
Returns
void
Implementation of
dispatchEvent()
dispatchEvent<
K>(type, ...args):void
Defined in: libs/base/src/event.ts:138
Synchronously invoke the affected event listeners with an event object
Type Parameters
K
K extends string | number | symbol
Parameters
type
K
args
...X[K]
Returns
void
false if the event was canceled, otherwise true