Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change subscribe method / enhace docstrings #12

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions pybondi/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,24 @@ class Session:
@classmethod
def add_event_handler(cls, event_type: type[Event], handler: Callable[[Event], None]):
"""
Adds an event handler for a given event type.
Adds an event handler for a given event type, when a new session is created
if no message bus is provided.
"""
cls.event_handlers.setdefault(event_type, []).append(handler)

@classmethod
def add_command_handler(cls, command_type: type[Command], handler: Callable[[Command], None]):
"""
Adds a command handler for a given command type.
Adds a command handler for a given command type, when a new session is created
if no message bus is provided.
"""
cls.command_handlers[command_type] = handler

@classmethod
def subscribe(cls, subscriber: Subscriber):
def add_subscriber(cls, subscriber: Subscriber):
"""
Subscribes a subscriber to the session.
Add a subscriber to the publisher session, when a new session is created
if no publisher is provided.
"""
cls.subscribers.append(subscriber)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pybondi"
version = "0.2.6"
version = "0.2.7"
description = "A lightweight library for creating event driven systems using domain driven design."
authors = ["Eric Cardozo <[email protected]>"]
license = "MIT"
Expand Down