Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commands and events #3

Open
huntc opened this issue Oct 2, 2022 · 0 comments
Open

Commands and events #3

huntc opened this issue Oct 2, 2022 · 0 comments

Comments

@huntc
Copy link

huntc commented Oct 2, 2022

Thanks for writing these notes.

On the statement that state machine transitions are neither functional or imperative, they can also be both. We distinguish commands and events. Commands drive state machines and events are emitted by them and reflect what has happened. Commands can be side effecting and emit an event. An event is then applied to a state to yield another state and has no side effects ie it is a pure function. This is useful when event sourcing to reconstitute state as events can be replayed without side effects.

Here’s a blog I wrote on this topic a while back: http://christopherhunt-software.blogspot.com/2021/02/event-driven-finite-state-machines.html

Here’s an implementation of what the blog describes using Rust: http://christopherhunt-software.blogspot.com/2021/02/event-driven-finite-state-machines.html

I’d be interested in your thoughts regarding what we’ve done. Thanks again for your work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant