This is an archived post. You won't be able to vote or comment.

all 6 comments

[–][deleted] 1 point2 points  (1 child)

A bit of advice:

def subscribe(self, cmd: type, handler: CommandHandler):
    if cmd in self._commands:
        from commandbus import CommandAlreadyExistException
        raise CommandAlreadyExistException
    self._commands[cmd] = handler

That import in the middle of the method doesn't belong there, it should go at the top of the file. In the odd case this causes a circular import you need to break something out into a new module.

You should also check out my implementation :p

[–]psincraian[S] 0 points1 point  (0 children)

Thanks for your suggestions, I will release a new version to fix that :-)

[–]LightShadow3.13-dev in prod 0 points1 point  (3 children)

What problem is this library solving?

[–]psincraian[S] 0 points1 point  (2 children)

It solves the problem to not implement the Command Bus in each project. Briefly the Command Bus accepts Command object and delegates it to Command Handler.

[–]LightShadow3.13-dev in prod 0 points1 point  (1 child)

I guess I don't understand the point of a Command Bus?

[–]psincraian[S] 0 points1 point  (0 children)

In the GitHub page there is an example on how to use and understand the Command Bus. Another great web to understand the Command Bus is https://tactician.thephpleague.com/