This repository was archived by the owner on Jan 10, 2018. It is now read-only.
feat(switchReduce): Added type safety way to reduce state#416
Open
gionkunz wants to merge 1 commit intongrx:masterfrom
Open
feat(switchReduce): Added type safety way to reduce state#416gionkunz wants to merge 1 commit intongrx:masterfrom
gionkunz wants to merge 1 commit intongrx:masterfrom
Conversation
Author
|
I just saw this is somewhat an extension to #382 |
|
Currently on my reducer functions I can always see the type of the payload. The only thing that isnt type safe on my current project is the return of the Does this solves the describe problem with toPayload by any luck? That would be awesome |
Author
|
I guess the operator could be extended in such a way, ill take a look |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
switchis 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 useswitchReducein conjunction withTypedAction<T>which I've also added to the README.md. What do you think?