commandServiceBuilder
Takes a list of actions and a repository and returns an object where action names map to executable commands.
Each command accepts an id and a payload. When invoked, a command loads the current state of the entity from the repo and passes it, and the payload, to the action. The action will perform its validation and if successful, generate one or more events. The command forwards those events to the repository to be appended to the entity.
build({ actions, repository })
Turns actions into commands that can be executed on real objects.
attribute | type | description |
actions | object | |
repository | object | generated by the repositoryBuilder |
commands
- where keys are actions names and values are functions which accept an id
and payload
Last modified 4yr ago