Events
- class Event[source]
Base class for Events.
Add fields to your subclass, whatever is needed to communicate the event to your
Handlerclass(es). An Event itself does not do anything but carry data to its Handler(s).Using
@defineandfieldfrom attrs is recommended to keep it short.
- class Handler(event: Event)[source]
Abstract base class for handling one or more
Event.Event handlers should do as little as possible, such as send a quick notification, log an action, or issue Command(s). If an Event implies anything significant needs to be done in response, the Handler should return
Commandobject(s). We can’t enforce this guideline for you, but recommend you follow it.Your handler may return a list containing
Commandand/orReturnMessageobjects.If one or more
ReturnMessageare returned, your application should do something with them.Note
Event handlers are located by searching through all subclasses of
Handler, to find Handler(s) that accept the Event. They are cached once located. If any of your Handlers are not being used when they should be, make sure they are imported when your application starts up. Usually, importing them in an__init__.pyfile or keeping them in the same file with theirEventwill fix it.