Whistle - Event Dispatcher¶
Whistle is a lightweight Python library for decoupled application communication through event dispatching and listening. It enables components to interact without direct dependencies, making your code more modular, testable, and maintainable.
from whistle import EventDispatcher
dispatcher = EventDispatcher()
@dispatcher.listen("user.registered")
def send_welcome_email(event):
print(f"Welcome, {event.username}!")
dispatcher.dispatch("user.registered")
Features¶
Synchronous and asynchronous dispatching - Choose the right dispatcher for your use case
Priority-based listener execution - Control the order listeners run
Event propagation control - Stop event flow when needed
Type safety - Prevent mixing sync and async listeners
Custom events - Attach domain-specific data to events
Zero dependencies - Lightweight and easy to integrate
Learning Path¶
Follow this guide to learn Whistle from basics to advanced usage:
Getting Started
Core Features
Advanced Usage
Reference
Quick Links¶
Getting Started - Start here if you’re new
Common Patterns - Common recipes and best practices
whistle - Complete API documentation