Class: abstract
Observable
Defined in: packages/core/src/event/Observable.ts:8
An Observable is a class that manages event listeners and allows distributing events to the registered listeners. It maintains a history of events and supports persistent events that are not cleared during route changes.
Extended by
Constructors
new Observable()
new Observable():
Observable
Returns
Methods
clear()
clear():
Observable
Defined in: packages/core/src/event/Observable.ts:35
Clears all persistent events, observers, and activity history from the observable.
This method will remove all stored events, registered observers, and any recorded activity history, effectively resetting the observable to its initial state.
Returns
The instance of the Observable for chaining.
destroy()
destroy():
Observable
Defined in: packages/core/src/event/Observable.ts:23
Destroys the observable by clearing its internal state and removing all event listeners.
Returns
The instance of the Observable for chaining.
init()
init():
Observable
Defined in: packages/core/src/event/Observable.ts:14
Initializes the observable.
Returns
The instance of the Observable for chaining.
registerPersistenEvent()
registerPersistenEvent<
E
>(event
):this
Defined in: packages/core/src/event/Observable.ts:57
Type Parameters
• E extends keyof DispatcherEventsMap
Parameters
event
E
Returns
this
Deprecated
Use the correctly spelled registerPersistentEvent
method instead.
registerPersistentEvent()
Call Signature
registerPersistentEvent<
E
>(event
):this
Defined in: packages/core/src/event/Observable.ts:45
Registers an event as persistent, meaning its history won't be cleared upon calling the clear
method (route change).
Type Parameters
• E extends keyof DispatcherEventsMap
Parameters
event
E
The name of the event to be registered as persistent. This can be a key from the DispatcherEventsMap or any string.
Returns
this
The instance of the Observable for chaining.
Call Signature
registerPersistentEvent(
event
):this
Defined in: packages/core/src/event/Observable.ts:46
Registers an event as persistent, meaning its history won't be cleared upon calling the clear
method (route change).
Parameters
event
string
The name of the event to be registered as persistent. This can be a key from the DispatcherEventsMap or any string.
Returns
this
The instance of the Observable for chaining.
subscribe()
Call Signature
subscribe<
E
>(event
,observer
,scope
?):this
Defined in: packages/core/src/event/Observable.ts:75
Subscribes an observer to a specific event. When the event is dispatched, the observer will be notified and executed within the provided scope. If the event has already occurred, the observer will be immediately invoked with the historical data.
Type Parameters
• E extends keyof DispatcherEventsMap
Parameters
event
E
The event to subscribe to.
observer
DispatcherListener
<DispatcherEventsMap
[E
]>
The observer function to be called when the event is dispatched.
scope?
unknown
The scope in which the observer function should be executed. This is optional.
Returns
this
The instance of the Observable for chaining.
Call Signature
subscribe(
event
,observer
,scope
?):this
Defined in: packages/core/src/event/Observable.ts:80
Subscribes an observer to a specific event. When the event is dispatched, the observer will be notified and executed within the provided scope. If the event has already occurred, the observer will be immediately invoked with the historical data.
Parameters
event
string
The event to subscribe to.
observer
DispatcherListener
<any
>
The observer function to be called when the event is dispatched.
scope?
unknown
The scope in which the observer function should be executed. This is optional.
Returns
this
The instance of the Observable for chaining.
unsubscribe()
Call Signature
unsubscribe<
E
>(event
,observer
,scope
?):this
Defined in: packages/core/src/event/Observable.ts:101
Unsubscribes an observer from a specific event.
Type Parameters
• E extends keyof DispatcherEventsMap
Parameters
event
E
The event name or key from the DispatcherEventsMap.
observer
DispatcherListener
<any
>
The observer (listener) to be unsubscribed.
scope?
unknown
Optional scope to be used for the observer.
Returns
this
The current instance for chaining.
Call Signature
unsubscribe(
event
,observer
,scope
?):this
Defined in: packages/core/src/event/Observable.ts:106
Unsubscribes an observer from a specific event.
Parameters
event
string
The event name or key from the DispatcherEventsMap.
observer
DispatcherListener
<any
>
The observer (listener) to be unsubscribed.
scope?
unknown
Optional scope to be used for the observer.
Returns
this
The current instance for chaining.