Skip to content

Commit

Permalink
EventCommandMapper now returns list of commands (backwards compatible)
Browse files Browse the repository at this point in the history
  • Loading branch information
douwevandermeij committed Aug 30, 2024
1 parent 41324b5 commit 351ce8b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion fractal/__init__.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion fractal/core/event_sourcing/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]

Expand Down

0 comments on commit 351ce8b

Please sign in to comment.