python-dependency-injector/examples/miniapps/commands-and-handlers/application/messagebus.py

15 lines
322 B
Python
Raw Permalink Normal View History

2020-11-21 02:09:34 +03:00
"""Message bus module."""
from typing import Dict, Callable, Any
from .commands import Command
class MessageBus:
def __init__(self, command_handlers: Dict[str, Callable[..., Any]]):
self.command_handlers = command_handlers
def handle(self, command: Command):
self.command_handlers[command]()