xtr_event_dispatcher.decorator ¶
Declaring listeners where they are written, for a container to register.
EventListenerDeclaration
dataclass
¶
EventListenerDeclaration(event: str | type | None = None, method: str | None = None, priority: int | None = None, dispatcher: str | None = None, before: tuple[OrderTarget, ...] = (), after: tuple[OrderTarget, ...] = ())
One @as_event_listener on a class, a method or a function.
Attributes:
-
event(str | type | None) –The event listened to;
Nonereads it from the type of the listener's first parameter. -
method(str | None) –The method to call;
Noneon a class pickson_<event>or__call__, and on a function calls it. -
priority(int | None) –The priority declared,
Nonewhen none was. -
dispatcher(str | None) –The named dispatcher to listen on;
Nonefor the default one. -
before(tuple[OrderTarget, ...]) –Listeners this one must run before.
-
after(tuple[OrderTarget, ...]) –Listeners this one must run after.
listeners_declared_on ¶
Return every listener @as_event_listener declared on obj.
On a function, its own declarations. On a class, those on the class itself, then those on its methods — inherited, static and class methods included — each naming the method it sits on.
Raises:
-
InvalidListenerError–When a declaration on a method names a method to call: it is the method it sits on.