Created
February 22, 2025 15:54
-
-
Save fredgrott/fec42302208b0435c36da6b9d422782d to your computer and use it in GitHub Desktop.
cqrs demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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