Catalog PyPI
Back to packageRELEASE DETAILS

0.0.1

PyPI

aioemit

A minimalistic async event bus implementation

aioemitasyncbusemitemittereventpublishpubsubsubscribe
Published29 May 2023
Direct dependencies0
Transitive dependenciesNot calculated

README

Version 0.0.1 documentation

aioemit

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.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 0

Native requirements
0 direct targetsNot calculated transitive count
No declared dependencies in this collected response

Declarations describe requirements; they are not a resolved dependency graph.

Distribution files

2 collected
aioemit-0.0.1-py3-none-any.whl

bdist_wheel · 4.86 KB · Python py3

Source file
aioemit-0.0.1.tar.gz

sdist · 3.92 KB · Python source

Source file

Metadata history

Meaningful changes
Current collected state Current

Observed since 21 Oct, 11:51 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:99c40d194dca403d4dcf3f291197c2f073fe71cd738bcf34755d3c49f8c6de14

Other collected versions

View all collected versions →