TypeDux / Redux / ReTyped
** DOCS NEED UPDATING, USE v2 FOR NOW **
A leaf based TypeScript 4 Immutable wrapper around REDUX - all decoration driven
To start, like everyone else, I love the benefits of an immutable functional paradigm, but the overhead of implementing it in the real world consistently proves difficult for a number of reasons
- Learning curve
- Type Safety
- Re-usability
- Scope access
- Integration into a current application
The issues arise from a completely decoupled solution, which in practice provides an optimal usage pattern, but provides hurdle after hurdle in terms of learning and on-boarding as well as reusing existing code.
Enter TypeDux, simply put it's redux with an immutable & observable root state that is statically typed at every node and end, reuse and manage
Install
Same as every other package, note that reflect-metadata, ImmutableJS and Redux are peer dependencies
NOTE: Runtime requires ES6 level polyfills - so babel-polyfill or transform-runtime, etc work just fine
npm i --save typdux
Getting Started
- Create a leaf state and message (message is optional, only for typescript and can be any)
//Typescript /** * Leaf record defines allowed props */ /** * Mock leaf state, dumb test state with test props */ /** * Typed action message (optional) */
- Create an
ActionFactory
//Typescript
- Create the store
NOTE: ALL ACTION FACTORIES AND DECORATIONS MUST BE LOADED BEFORE CREATING THE STORE
// Typescript
- Observe store keys and leafs
// Create an observer // Unsubscribe when doneunsub
CREDIT
Jonathan Glanz @jglanz