aioemit
aioemit allows you to manage events asynchonosly and notify subscribers when those events occur. It provides a simple way to implement event bus pattern in an event driven architecture application.
Installation
pip install aioemit
Usage
Creating Events
The Event class represents an event with a specified event type and optional data. You can create an event by initializing an instance of the Event class with the event type and data (if any).
event = Event("example_event", "example_data")
Creating an Emitter
To use the event emitter, create an instance of the Emitter class.
emitter = Emitter()
Subscribing to Events
To subscribe to events, use the subscribe method of the Emitter class. Pass the event type and an observer function that will be called when the event is emitted.
def event_observer(event):
# Handle the event
print("Received event:", event)
emitter.subscribe("example_event", event_observer)
Unsubscribing from Events
If you no longer want to receive notifications for a specific event, you can unsubscribe from it using the unsubscribe method. Provide the event type and the observer function that you want to remove.
emitter.unsubscribe("example_event", event_observer)
Emitting Events
To emit an event and notify all subscribers, use the emit method of the Emitter class. Pass the event you want to emit.
event = Event("example_event", "example_data")
await emitter.emit(event)
The emit method will asynchronously call all the subscribed observer functions that are associated with the event type.
License
This project is licensed under the MIT License. Feel free to use, modify, and distribute the code as per the terms of the license.
Metadata
Release files for aioemit 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aioemit-0.0.1.tar.gz | 4.0 kB | Without provenance | Details for aioemit-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aioemit-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for aioemit-0.0.1-py3-none-any.whl |
Total release size: 9.0 kB
Release files / aioemit-0.0.1.tar.gz
| Download URL | aioemit-0.0.1.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
811be2be0647d46afe64becc1c7ce09da782eea45ebe5dc379c93b35f3897d40
|
|
BLAKE2b-256 checksum How to use checksums |
dfa523a4d79c0160983ec3a55e9c7dca38922fe8b94236b0053b367465a940d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0rc1
|
Release files / aioemit-0.0.1-py3-none-any.whl
| Download URL | aioemit-0.0.1-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8aa6cab24a1ce018e75729c3de23aceac14c167bee4d7ec0d73c85c7d42d7efc
|
|
BLAKE2b-256 checksum How to use checksums |
2b304aee731bc915b705b4535d9e8b0b6f9b9cdab351b524a3fd419931768deb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0rc1
|
Security for aioemit 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.