This repository has been archived by the owner on Jan 10, 2018. It is now read-only.
feat(switchReduce): Added type safety way to reduce state #416
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've been trying to work out a preferred solution for me when dealing with reducers. I wanted to have type safety so that I don't need to guess what the payload of an action is. This is the result which I currently use in my project and I think it would be valuable for many other developers. Also I think
switch
is the worst language construct that ever existed (right after goto) and I believe we should try to reduce the amount of developers who need to use it. It's error prone, unsafe and a complete syntax mess. This is an example of how to useswitchReduce
in conjunction withTypedAction<T>
which I've also added to the README.md. What do you think?