core.events package
Submodules
core.events.event module
Creation, retrieval, posting and deletion of events using Forge’s custom event management system.
- class core.events.event.Event(name: str, _subscribers: dict[typing.Callable[[typing.Any, ...], NoneType], tuple[typing.Any, ...]] = <factory>)
Bases:
object
Forge’s basic but sufficient event system for both internal and developer use.
- name: str
- post() None
Post the event that calls all of its subscriber functions with their respective arguments. If an exception occurs when calling a subscriber function, it is ignored and printed to the console.
- core.events.event.delete_event(event_name: str) None
Delete a registered event from the event dictionary. Acts as an abstraction over the package-protected dictionary. Also does not allow deletion of an internal event.
- Parameters
event_name (str) – Name of the event to delete.
- Raises
ValueError – Internal events cannot be deleted.
KeyError – Event must be present in the event dictionary to delete.
- core.events.event.get_event(event_name: str) Event
Get a registered event from the event dictionary. Acts as an abstraction over the package-protected dictionary. Also does not allow getting an internal event.
- Parameters
event_name (str) – Name of the event to retrieve.
- Returns
Event from the dictionary with the same name.
- Return type
- Raises
ValueError – Internal events cannot be retrieved.
KeyError – Event must be present in the event dictionary to retrieve.