Word of Caution
However, in the spirit of unifying the Reason community around an authoritative Redux implementation and to avoid churn, we'll polish Reductive to make it production-ready for those who do wish to use it anyway.
Comparisons with Redux
Redux actions are implemented as plain JS objects. JS objects can be a bit too flexible, and many Redux users rely on standardized shapes for their actions to make sure that middlewares and third party libraries work with them. Reason has language-level support for composing a set of data types which many functions can operate over. They are called variants and you can see how they are used here.
Redux action creators are used as composable ways of generating plain JS objects that match the schema of a specific action. In Reason, the type system does a lot of this work for you, so you can reliably put action types directly in your code and know that things will Just Work™. This has an added performance advantage of shifting that function call to compile time.
Much of the power of redux comes from having a unified API for writing and using middleware or enhancers. They're typically wired together behind the scenes in the applyMiddlewares function. This function doesn't exist in Reductive, because Reason has language-level support for function composition with operators like
@@. You can see some example usage here and some of the deprecation messages to get a better understanding of typical usage.
The code behind Reductive is incredibly simple. The first 40 lines Include the entire reimplementation of redux. The next ~40 lines are a reimplementation of the react-redux library (without the higher-order component connect style implementation). The code is short and relatively simple to follow.
Alternative to Reductive
Hopefully, the above comparisons demonstrated that you might not need an extra-react state management technique at all; passing props down works well in Reason-React, and since props are well-typed, adding/remove them takes seconds. Keep state/props management simple so that you can spend the learning budget elsewhere!
- Potential bug fixes
- Better examples usages
- More docs on differences from/similarities with Redux
- Different examples of/links to simpler state management in Reason