combus is a simple commandbus for Python 3.7+
pipenv:
pipenv install combus
pip:
pip install combus
From source:
python setup.py install
class FooHandler(CommandHandler):
def _handle(self, command: Command):
# do something with the command
class FooCommand(Command):
def __init__(self, foo):
self._foo = foo
@property
def foo(self):
return self._foo
bus = CommandBus()
bus.link_command_with_handler(FooCommand.__name__, FooHandler())
bus.handle(FooCommand(foo="bar"))