Recently the Clojure team released an alpha version of the core.async library that includes a new library named Flow. While the new functionality is amazing and is already inspiring devs to use it, this post is not about Flow. Instead, I'd like to talk about a small part of the Flow API where process behavior is implemented in terms of step-fns. Simply put, step-fns are functions of four arities, where each arity is called at key points in the life-cycle of a process to provide configuration information or perform behaviors.
The four arities are as follows:
- Describe the step-fn by returning a data-structure describing its boundaries
- Returns the initialization state for the enclosing process given compatible arguments
- Called every time a life-cycle transition occurs with a state and transition key and returns an updated state
- Called in a loop for every mes