Basic Event Handling System
Project description
ondosense-eventhandling
ondosense-eventhandling provides a basic implementation for event handling.
Example Usage
from ondosense.eventhandling import Event, EventDispatcher, EventSubscriber
from typing import List, Tuple
class SendGreetingsEvent(Event):
name = 'greeting'
_message: str = 'Hello World!'
@property
def message(self) -> str:
return self._message
class GreetingSubscriber(EventSubscriber):
def get_subscribed_events(self) -> dict[str, List[Tuple[str, int]]]:
return {
SendGreetingsEvent.name: [
('send_simple_greetings', 10),
('send_important_greetings', 20),
],
}
def send_simple_greetings(self, event: SendGreetingsEvent) -> None:
print(event.message)
def send_important_greetings(self, event: SendGreetingsEvent) -> None:
important_message = f"!!! {event.message} !!!"
important_message_length = len(important_message)
print("!" * important_message_length)
print(important_message)
print("!" * important_message_length)
(
EventDispatcher()
.add_subscriber(GreetingSubscriber())
.dispatch(SendGreetingsEvent())
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ondosense_eventhandling-0.1.2-py3-none-any.whl.
File metadata
- Download URL: ondosense_eventhandling-0.1.2-py3-none-any.whl
- Upload date:
- Size: 2.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14020dcc0eb75a7c9a56393bc5dd7d24283958ad43de2e948b1885e3672e8c55
|
|
| MD5 |
4a15e8e22d167b0278fa2f49cb7ab02f
|
|
| BLAKE2b-256 |
31d5852b04a6bf30944a56c01308dae714e975f78e1642736c17c51ebb121462
|