Skip to content

Commit

Permalink
feat: global notification handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
chessenjoyer17 committed Jan 21, 2025
1 parent e30450b commit f90a825
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ where = ["src"]

[project]
name = "bazario"
version = "0.3.0"
version = "0.4.0"
readme = "README.md"
authors = [{ name = "Alim Abrekov", email = "[email protected]" }]
description = "Lightweight handler routing library for modular apps."
Expand Down
7 changes: 6 additions & 1 deletion src/bazario/asyncio/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ def get_notification_handlers(
self,
notification_type: type[Notification],
) -> list[type[NotificationHandler]]:
return self.notification_handlers.get(notification_type, [])
return [
handler
for notification, handlers in self.notification_handlers.items()
for handler in handlers
if issubclass(notification_type, notification)
]

def get_pipeline_behaviors(
self,
Expand Down
7 changes: 6 additions & 1 deletion src/bazario/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ def get_notification_handlers(
self,
notification_type: type[Notification],
) -> list[type[NotificationHandler]]:
return self.notification_handlers.get(notification_type, [])
return [
handler
for notification, handlers in self.notification_handlers.items()
for handler in handlers
if issubclass(notification_type, notification)
]

def get_pipeline_behaviors(
self,
Expand Down

0 comments on commit f90a825

Please sign in to comment.