A library that helps representing Redux Actions as an Algebraic Union Type in JavaScript.
In helps to describe state transitions in a type-safe manner with exhaustive Action coverage.
const Actions = withCase(fromObject({
Increment: PropTypes.any,
Decrement: PropTypes.any,
DecrementBy: PropTypes.number
}));
const reducer = Actions.case({
Increment: state => state + 1,
Decrement: state => state - 1,
DecrementBy: (state, number) => state - number,
_: (state = 0) => state
});
const store = createStore(reducer);
store.dispatch(Actions.Increment())