Interface IReadonlyObservable<T>
interface IReadonlyObservable<T = unknown> {
add(
callback: (eventData: T, eventState: EventState) => void,
mask?: number,
insertFirst?: boolean,
scope?: unknown,
unregisterOnFirstCall?: boolean,
): IObserver;
addOnce(
callback: (eventData: T, eventState: EventState) => void,
): IObserver;
}
add(
callback: (eventData: T, eventState: EventState) => void,
mask?: number,
insertFirst?: boolean,
scope?: unknown,
unregisterOnFirstCall?: boolean,
): IObserver;
addOnce(
callback: (eventData: T, eventState: EventState) => void,
): IObserver;
}
Type Parameters
- T = unknown
Implemented by
Methods
add
-
add(
callback: (eventData: T, eventState: EventState) => void,
mask?: number,
insertFirst?: boolean,
scope?: unknown,
unregisterOnFirstCall?: boolean,
): IObserverCreate a new Observer with the specified callback
Parameters
- callback: (eventData: T, eventState: EventState) => void
the callback that will be executed for that Observer
Optionalmask: numberthe mask used to filter observers
OptionalinsertFirst: booleanif true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
Optionalscope: unknownoptional scope for the callback to be called from
OptionalunregisterOnFirstCall: booleandefines if the observer as to be unregistered after the next notification
Returns IObserver
the new observer created for the callback
- callback: (eventData: T, eventState: EventState) => void
add Once
-
Create a new Observer with the specified callback and unregisters after the next notification
Parameters
- callback: (eventData: T, eventState: EventState) => void
the callback that will be executed for that Observer
Returns IObserver
the new observer created for the callback
- callback: (eventData: T, eventState: EventState) => void
An interface that defines the reader side of an Observable (receive notifications).