type ObservableObject.AttachListener
Type definition for a callback, or set of callbacks that can be passed to the ObservableObject.attach method.
type AttachListener<T extends ObservableObject> =
| ((event: ObservableEvent) => Promise<void> | void)
| {
handler?: (object: T, event: ObservableEvent) => Promise<void> | void;
detached?: (object: T) => void;
}
| {
delegate?: ObservableObject.EventDelegate;
detached?: (object: T) => void;
};
Notes
- If a single function is provided, it will be called for all events emitted by the object.
- If an object with
handlerproperty is provided, that function will be called for all events, and thedetachedfunction will be called when the object is detached or unlinked. - If the object includes a
delegateproperty instead ofhandler, the delegate runs after alllisten()handlers, allowing listeners to callstopPropagation(). If the event is not stopped and the delegate method returns falsy, the event bubbles up to the parent.
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.
