saealib.CallbackManager¶
- class saealib.CallbackManager[source]¶
Bases:
objectManages event handlers.
Handlers are registered per concrete event type and called in registration order when an event of that type is dispatched.
Methods
Initialize CallbackManager. |
|
Invoke all handlers registered for the type of event. |
|
Register a handler for an event type. |
|
Replace a registered handler with another. |
|
Remove a previously registered handler. |
Method Details
- CallbackManager.dispatch(event)[source]¶
Invoke all handlers registered for the type of event.
- Parameters:
event (Event) – The event object to dispatch. Handlers receive this object directly and may modify its mutable fields.
- Return type:
None
- CallbackManager.register(event_type, func)[source]¶
Register a handler for an event type.
- Parameters:
event_type (type[E]) – The concrete event class to listen for.
func (Callable[[E], None]) – Handler function. Receives the event object and returns nothing.
- Return type:
None
- CallbackManager.replace(event_type, old, new)[source]¶
Replace a registered handler with another.
- Parameters:
event_type (type[E]) – The event class whose handler list to modify.
old (Callable[[E], None]) – The handler to replace. Raises
ValueErrorif not found.new (Callable[[E], None]) – The replacement handler.
- Return type:
None