type ObservableObject.Listener
Type definition for a callback, or set of callbacks that can be passed to the ObservableObject.listen method.
type Listener<T extends ObservableObject> =
| ((this: T, event: ObservableEvent) => Promise<void> | void)
| {
handler?: (object: T, event: ObservableEvent) => Promise<void> | void;
unlinked?: (object: T) => void;
init?: (object: T, stop: () => void) => void;
};
Notes
- If a single function is provided, it will be called for all events emitted by the object.
- If an object is provided, the
handlerfunction will be called for all events, and theunlinkedfunction will be called when the object is unlinked. - The
initfunction is called immediately, with the object and a callback to remove the listener.
Instance members
handler
A function that will be called for all events emitted by the object.unlinked
A function that will be called when the object is unlinked.init
A function that is called immediately, with both the object and a callback to remove the listener.
Related
class ObservableObject
The base class of all observable objects, which can be placed into a tree structure to enable event handling and data binding.
