class Rooibos::Command::Batch

A fire-and-forget parallel command.

Applications fetch data from multiple sources. Dashboard panels load users, stats, and notifications. Waiting sequentially is slow. Managing threads and error handling manually is error-prone.

This command runs children in parallel. Each child sends its own messages independently. The batch completes when all children finish or when cancellation fires. On cancellation, emits Command.cancel(self).

Use it for parallel fetches, concurrent refreshes, or any work that does not need coordinated results.

Example

def update(msg, model)
  case msg
  in :refresh_all
    batch = Command.batch(
      Command.http(:get, "/users", :users),
      Command.http(:get, "/stats", :stats),
    )
    [model.with(loading: true), batch]
  in :users | :stats
    [model.with(msg => data), nil]
  end
end