March 2025
Intermediate to advanced
202 pages
4h 45m
English
Let’s take baby steps toward event sourcing. As with most of life, the journey turns out to be more rewarding than the end goal. In the previous section, you created a stateless, imperative calculator.
An imperative is another word for a command, and we can think of function calls like add, sub, mul, and div as commands. Maintaining state in functional languages is a pretty hefty topic, but a common approach is to have state managed by things like Agents or GenServers and the code that produces state be held in reusable modules or libraries.
Let’s refactor the previous module so that instead of specific function calls it accepts commands with the current value (state) in the payload. The return value ...
Read now
Unlock full access