class Rooibos::Command::All

Aggregates parallel commands and returns all results together.

Dashboards load user profiles, settings, and stats before rendering. Fetching sequentially is slow. Fire-and-forget batches lose correlation between commands and their results.

This command runs children in parallel and collects their results into a single Message::All response. Pattern-match on the envelope to correlate results. Each result appears in the same order as commands.

Use it for coordinated fetches where you need all results before proceeding.

Prefer the Command.all factory method for convenience.

Example

# Using the factory method (recommended)
Command.all(:dashboard,
  Command.http(:get, "/users", :_),
  Command.http(:get, "/stats", :_),
)

# Using the class directly
All.new(:dashboard,
  Command.http(:get, "/users", :_),
  Command.http(:get, "/stats", :_),
)

# Pattern-match on the aggregated result
def update(message, model)
  case message
  in { type: :all, envelope: :dashboard, results: [users, stats] }
    model.with(users:, stats:, loading: false)
  end
end