bec_lib.callback_handler.CallbackHandler#
- class CallbackHandler[source]#
Bases:
object
Callback handler class
Methods
Generate a new callback id
Run all pending callbacks
Register a callback to an event type
Register multiple callbacks to an event type
Remove a registered callback by its id
Run all callbacks for a given event type
- register(event_type: str, callback: Callable, sync=False) int [source]#
Register a callback to an event type
- Parameters:
event_type (str) – Event type
callback (Callable) – Callback function
sync (bool, optional) – Synchronous or async callback. Defaults to False.
- Returns:
Callback id
- Return type:
int
- register_many(event_type: str, callbacks: list[Callable], sync=False) list[int] [source]#
Register multiple callbacks to an event type
- Parameters:
event_type (str) – Event type
callbacks (list[Callable]) – List of callback functions
sync (bool, optional) – Synchronous or async callback. Defaults to False.
- Returns:
List of caallback ids
- Return type:
list