Fusio(n) Reactor
Worflow management based on Elm Architecture
Fusio(n) Reactor is a basic declarative worflow mangement that is inspired by Elm Architecture. It comes with out of the box connectors for Redux, but it is useful in many other contexts, or with other libraries.
If you need complex workflows, use Redux Saga, it is way more powerful.
Concepts
While Redux only handles state changes, this library handles both state changes and declarative side-effects in the same place. By having them colocated, it provides a clear view of the results.
A worflow is a function that will take a state and a context and will return the next state and a description of the side-effects to be performed.
The library comes with some helpers that facilitate that (reference
, task
, chain
, batch
. error
). It also offers a set of helpers to connect to Redux (enhanceReducer
, createMiddleware
).
Reference
The reference is just a simple way to create a worflow with no side-effects. Does nothing except wrap the state and context and pass them further. This is the ideal way to only change the state.
Task
The task is a way to wrap a promise into a workflow.
Chain
A chain is allowing composition of worflows that will be run in sequence. It also allows the to handle errors on the previous workflows.
Batch
A batch is allowing composition of worflows that will be run in parallel. It merges all the worflows into one after every one of them finishes.
Error
The error wrapper transforms a failed worflow into a successful one. This is probably rarely needed, but in some cases we want to catch the error and continue our worflow.
Setup
yarn add fusio
or
npm install --save fusio
Usage
Before you start import the functions from the library
Connect to Redux
// Create the store // Mapconst updates = CREATE_PLAYER // Create the saga middlewareconst fusioMiddleware = // Mount it on the Storeconst store = // Load the dispatch valuestore