class Rooibos::Command::Mapped

Wraps another command’s result with a transformation.

Fractal Architecture requires composition. Child fragments produce commands with their own tags. Parent fragments need those results routed back with a parent prefix. Without transformation, update functions become monolithic ā€œGod Reducersā€ that know about every child’s internals.

This command wraps an inner command and transforms its result message. The parent fragment delegates to the child, then intercepts the result and adds its routing prefix. Clean separation. No coupling.

Use it to compose child fragments that return their own commands.

Prefer the Command.map factory method for convenience.

Example

# Using the factory method (recommended)
Command.map(child_command) { |msg| [:sidebar, msg] }

# Using the class directly
Mapped.new(inner_command: child_command, mapper: ->(msg) { [:sidebar, msg] })