# ALT-event-system
> A lightweight, flexible publish-subscribe event system for Python applications.
[](https://badge.fury.io/py/ALT-event-system)
[](https://pypi.org/project/ALT-event-system/)
[](https://opensource.org/licenses/MIT)
## Overview
ALT-event-system provides a simple yet powerful event-driven architecture that enables loose coupling between components through an event bus pattern. Perfect for building reactive applications, plugin systems, or any scenario where you need decoupled communication.
## Features
- 🚀 **Simple API** - Easy to understand and use
- 🎯 **Type-safe** - Full type hints for better IDE support
- 🔌 **Loose Coupling** - Components communicate without direct dependencies
- 🌟 **Wildcard Subscriptions** - Subscribe to all events with `*`
- 📜 **Event History** - Track and query past events
- 🛡️ **Error Isolation** - Handler errors don't affect other handlers
- 🔍 **Source Tracking** - Optional source identification for events
- ⚡ **Zero Dependencies** - Uses only Python standard library
## Installation
```bash
pip install ALT-event-system
```
## Quick Start
```python
from alt_event_system import EventSystem
# Create an event system
events = EventSystem()
# Define a handler
def on_user_login(event):
print(f"User {event.data['user_id']} logged in from {event.data['ip']}")
# Subscribe to events
events.subscribe("user.login", on_user_login)
# Emit events
events.emit("user.login", {"user_id": 123, "ip": "192.168.1.1"})
```
## Advanced Usage
### Wildcard Subscriptions
Subscribe to all events:
```python
def log_all_events(event):
print(f"[{event.timestamp}] {event.type}: {event.data}")
events.subscribe("*", log_all_events)
```
### Event History
Track and query past events:
```python
# Get recent events
history = events.get_history(limit=10)
# Filter by event type
login_events = events.get_history(event_type="user.login")
```
### Error Handling
Handler errors are isolated:
```python
def safe_handler(event):
print("I still work even if others fail!")
events.subscribe("test.event", safe_handler)
```
## API Reference
- `EventSystem()` - Create a new event system
- `subscribe(event_type, handler)` - Subscribe to events
- `emit(event_type, data, source=None)` - Emit an event
- `get_history(event_type=None, limit=100)` - Get event history
- `clear_history()` - Clear event history
- `get_subscriber_count(event_type)` - Count subscribers
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## Author
**Avi Layani** - [avilayani@gmail.com](mailto:avilayani@gmail.com)
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
Raw data
{
"_id": null,
"home_page": null,
"name": "ALT-event-system",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "events, event-driven, pubsub, publish-subscribe, event-bus, observer, messaging",
"author": null,
"author_email": "Avi Layani <avilayani@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/95/a4/251c0339908ab558b13f57fa75f4fe259e73bf5c2509611678614d286c8d/alt_event_system-0.1.0.tar.gz",
"platform": null,
"description": "# ALT-event-system\n\n> A lightweight, flexible publish-subscribe event system for Python applications.\n\n[](https://badge.fury.io/py/ALT-event-system)\n[](https://pypi.org/project/ALT-event-system/)\n[](https://opensource.org/licenses/MIT)\n\n## Overview\n\nALT-event-system provides a simple yet powerful event-driven architecture that enables loose coupling between components through an event bus pattern. Perfect for building reactive applications, plugin systems, or any scenario where you need decoupled communication.\n\n## Features\n\n- \ud83d\ude80 **Simple API** - Easy to understand and use\n- \ud83c\udfaf **Type-safe** - Full type hints for better IDE support\n- \ud83d\udd0c **Loose Coupling** - Components communicate without direct dependencies\n- \ud83c\udf1f **Wildcard Subscriptions** - Subscribe to all events with `*`\n- \ud83d\udcdc **Event History** - Track and query past events\n- \ud83d\udee1\ufe0f **Error Isolation** - Handler errors don't affect other handlers\n- \ud83d\udd0d **Source Tracking** - Optional source identification for events\n- \u26a1 **Zero Dependencies** - Uses only Python standard library\n\n## Installation\n\n```bash\npip install ALT-event-system\n```\n\n## Quick Start\n\n```python\nfrom alt_event_system import EventSystem\n\n# Create an event system\nevents = EventSystem()\n\n# Define a handler\ndef on_user_login(event):\n print(f\"User {event.data['user_id']} logged in from {event.data['ip']}\")\n\n# Subscribe to events\nevents.subscribe(\"user.login\", on_user_login)\n\n# Emit events\nevents.emit(\"user.login\", {\"user_id\": 123, \"ip\": \"192.168.1.1\"})\n```\n\n## Advanced Usage\n\n### Wildcard Subscriptions\n\nSubscribe to all events:\n```python\ndef log_all_events(event):\n print(f\"[{event.timestamp}] {event.type}: {event.data}\")\n\nevents.subscribe(\"*\", log_all_events)\n```\n\n### Event History\n\nTrack and query past events:\n```python\n# Get recent events\nhistory = events.get_history(limit=10)\n\n# Filter by event type\nlogin_events = events.get_history(event_type=\"user.login\")\n```\n\n### Error Handling\n\nHandler errors are isolated:\n```python\ndef safe_handler(event):\n print(\"I still work even if others fail!\")\n\nevents.subscribe(\"test.event\", safe_handler)\n```\n\n## API Reference\n\n- `EventSystem()` - Create a new event system\n- `subscribe(event_type, handler)` - Subscribe to events\n- `emit(event_type, data, source=None)` - Emit an event\n- `get_history(event_type=None, limit=100)` - Get event history\n- `clear_history()` - Clear event history\n- `get_subscriber_count(event_type)` - Count subscribers\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## Author\n\n**Avi Layani** - [avilayani@gmail.com](mailto:avilayani@gmail.com)\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A lightweight publish-subscribe event system for Python",
"version": "0.1.0",
"project_urls": {
"Bug Reports": "https://github.com/Avilir/ALT-event-system/issues",
"Homepage": "https://github.com/Avilir/ALT-event-system",
"Source": "https://github.com/Avilir/ALT-event-system"
},
"split_keywords": [
"events",
" event-driven",
" pubsub",
" publish-subscribe",
" event-bus",
" observer",
" messaging"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "322ea426d0a9be74e62d9dc7b57aafab06654f872d89241f2fa88d06339a1431",
"md5": "80c43296ae71bc071b04a76b1294253f",
"sha256": "de71ceea8c61f2278a6a44ad917772597f2589e4f0624939f2852d203f5f4fe3"
},
"downloads": -1,
"filename": "alt_event_system-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "80c43296ae71bc071b04a76b1294253f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 7228,
"upload_time": "2025-09-10T13:27:02",
"upload_time_iso_8601": "2025-09-10T13:27:02.150011Z",
"url": "https://files.pythonhosted.org/packages/32/2e/a426d0a9be74e62d9dc7b57aafab06654f872d89241f2fa88d06339a1431/alt_event_system-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "95a4251c0339908ab558b13f57fa75f4fe259e73bf5c2509611678614d286c8d",
"md5": "16ebb8edb4eddfd5ef5d4b5e257adbad",
"sha256": "daae85186b7ef78335cf756932cc32bf6cc02a8e9bcd833007e3f4c88e867ae5"
},
"downloads": -1,
"filename": "alt_event_system-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "16ebb8edb4eddfd5ef5d4b5e257adbad",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 9719,
"upload_time": "2025-09-10T13:27:03",
"upload_time_iso_8601": "2025-09-10T13:27:03.339826Z",
"url": "https://files.pythonhosted.org/packages/95/a4/251c0339908ab558b13f57fa75f4fe259e73bf5c2509611678614d286c8d/alt_event_system-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-10 13:27:03",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Avilir",
"github_project": "ALT-event-system",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "alt-event-system"
}