sequence static method

Cmd sequence(
  1. List<Cmd> commands
)

A command that runs commands in sequence.

Each command completes before the next starts. Each command's message is delivered as it completes, before the next command begins.

return (newModel, Cmd.sequence([
  initializeDatabase(),
  loadConfiguration(),
  startServer(),
]));

Implementation

static Cmd sequence(List<Cmd> commands) {
  if (commands.isEmpty) return none();
  if (commands.length == 1) return commands.first;

  return Cmd(() async => SequenceMsg(commands));
}