Skip to content

Instantly share code, notes, and snippets.

@fredgrott
Created February 22, 2025 15:54
Show Gist options
  • Save fredgrott/fec42302208b0435c36da6b9d422782d to your computer and use it in GitHub Desktop.
Save fredgrott/fec42302208b0435c36da6b9d422782d to your computer and use it in GitHub Desktop.
cqrs demo
main() async {
final cqrs = Cqrs()
..registerAggregate(AccountAggregate())
..registerRepository(InMemoryRepository<Account>(forAggregate: "account"));
cqrs.events.listen(print);
await cqrs.submitCommand(CreateAccountCmd(owner: "Teja", modelId: "1"));
await cqrs.submitCommand(DepositCmd(modelId: "1", amount: 200.0));
await cqrs.submitCommand(DepositCmd(modelId: "1", amount: 200.0));
await cqrs.submitCommand(WithdrawCmd(modelId: "1", amount: 300.0));
await cqrs.submitCommand(DepositCmd(modelId: "1", amount: 400.0));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment