module documentation

Generic event and event handling classes and functions.

Class Event Event subscription.
Class EventData Event data class. This class is used to pass data to event handlers.
Class EventManager Event topics are added as new methods to an EventManager instance. Events can be raised by calling those new methods.
Function EventHandler Class decorator to automatically register event handlers. Any method of the decorated class that is decorated with an Event decorator will be automatically registered as an event handler for that event.
Function onEvent Marks a method for event registration — deferred until instantiation.
Type Variable _F The F TypeVar on the decorator overload is important — it tells the type checker that whatever callable goes in comes back out unchanged, so the handler's own signature is preserved after decoration.
def EventHandler(cls: type) -> type:

Class decorator to automatically register event handlers. Any method of the decorated class that is decorated with an Event decorator will be automatically registered as an event handler for that event.

It is necessary to use this decorator for any class that has methods decorated with onEvent, otherwise the event handlers will not be registered and the decorated methods will not be correctly called when the event is raised.

def onEvent(event: Event) -> Callable[[_F], _F]:

Marks a method for event registration — deferred until instantiation.

_F =

The F TypeVar on the decorator overload is important — it tells the type checker that whatever callable goes in comes back out unchanged, so the handler's own signature is preserved after decoration.

Value
TypeVar('_F',
        bound=Callable)