Lightweight, strongly-typed event library for Python.
Project description
unboil-events
Lightweight, strongly-typed event library for Python.
Installation
pip install unboil-events
Quick Start
from unboil_events import SyncEvent, AsyncEvent
import asyncio
# 1. SyncEvent: simple synchronous events
evt = SyncEvent[str]()
@evt
def on_msg(msg: str) -> None:
print(f"Received: {msg}")
evt.invoke("Hello")
# 2. AsyncEvent: async listeners
async_evt = AsyncEvent[str]()
@async_evt
async def on_async(msg: str) -> None:
await asyncio.sleep(0.1)
print(f"Async received: {msg}")
# Sequential execution
await async_evt.ainvoke("Hi")
# Parallel execution (asyncio.gather)
await async_evt.ginvoke("Parallel Hi")
API
- SyncEvent[P] - register callables
Callable[P, None], invoke synchronously - AsyncEvent[P] - register
Callable[P, Awaitable[None]], invoke withainvokeorginvoke - BaseEvent[P] - Base class, return type is always
None.
Contributing
Pull requests welcome. Please run tests and follow code style.
License
MIT
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 Distribution
unboil_events-1.0.0.tar.gz
(4.5 kB
view details)
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 unboil_events-1.0.0.tar.gz.
File metadata
- Download URL: unboil_events-1.0.0.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3339c212477c2b82b624621753b8ef051815b8fafbed415735cf79c58d6b519f
|
|
| MD5 |
2fbc0086dd47577085c7c8d170a1b009
|
|
| BLAKE2b-256 |
2710b7232668bafc275705cefe473abd5ce681960d6e2345b3759f333965f0a2
|
File details
Details for the file unboil_events-1.0.0-py3-none-any.whl.
File metadata
- Download URL: unboil_events-1.0.0-py3-none-any.whl
- Upload date:
- Size: 2.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97cb02cafb983979e1133e5c2e461dc01eae5caf450a4cd528c4ec10d80bc72b
|
|
| MD5 |
f46440b5b1903c62c728ada53ecafd70
|
|
| BLAKE2b-256 |
dc26183ab1ecaf8c406420993cc92bfb117e5e1c2ab491edc11913f122485830
|