diff --git a/fractal/__init__.py b/fractal/__init__.py index 14561dc..e8e8a9b 100644 --- a/fractal/__init__.py +++ b/fractal/__init__.py @@ -1,6 +1,6 @@ """Fractal is a scaffolding toolkit for building SOLID logic for your Python applications.""" -__version__ = "5.1.0" +__version__ = "5.2.0" from abc import ABC diff --git a/fractal/core/event_sourcing/event.py b/fractal/core/event_sourcing/event.py index c800804..78ab175 100644 --- a/fractal/core/event_sourcing/event.py +++ b/fractal/core/event_sourcing/event.py @@ -45,5 +45,5 @@ def to_command(self): class EventCommandMapper(ABC): @abstractmethod - def mappers(self) -> Dict[Type[Event], List[Callable[[Event], Command]]]: + def mappers(self) -> Dict[Type[Event], List[Callable[[Event], List[Command]]]]: raise NotImplementedError diff --git a/fractal/core/event_sourcing/projectors/command_bus_projector.py b/fractal/core/event_sourcing/projectors/command_bus_projector.py index 35a1cec..d49e16f 100644 --- a/fractal/core/event_sourcing/projectors/command_bus_projector.py +++ b/fractal/core/event_sourcing/projectors/command_bus_projector.py @@ -25,4 +25,8 @@ def project(self, id: str, event: Union[SendingEvent, ReceivingEvent]): self.command_bus_func().handle(event.to_command()) elif event.__class__ in self.mappers: for mapper in self.mappers[event.__class__]: - self.command_bus_func().handle(mapper(event)) + commands = mapper(event) + if commands != list: # backwards compatibility + commands = [commands] + for command in commands: + self.command_bus_func().handle(command) diff --git a/pyproject.toml b/pyproject.toml index 79f3d4d..65487a0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "fractal-toolkit" -version = "5.1.0" +version = "5.2.0" description = "Fractal is a scaffolding toolkit for building SOLID logic for your Python applications." authors = ["Douwe van der Meij "]