Pyventus

0.8.0 · active · verified Wed Apr 15

Pyventus is a modern and robust Python library for event-driven and reactive programming. It provides a comprehensive suite of tools to define, emit, manage, and orchestrate events with ease, using customizable event emitters and flexible responses. The current version is 0.8.0. The library is actively maintained with a regular release cadence, ensuring ongoing compatibility and feature enhancements.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates the basic event-driven usage of Pyventus. It defines an event handler using the `@EventLinker.on` decorator for a 'GreetEvent' and then emits this event using an `AsyncIOEventEmitter` instance. When the event is emitted, the `handle_greet_event` function is called, printing 'Hello, World!'.

from pyventus.events import AsyncIOEventEmitter, EventEmitter, EventLinker

# Define an event handler using the EventLinker decorator
@EventLinker.on("GreetEvent")
def handle_greet_event():
    print("Hello, World!")

# Create an event emitter instance
event_emitter: EventEmitter = AsyncIOEventEmitter()

# Emit the custom event, triggering the handler
event_emitter.emit("GreetEvent")

view raw JSON →