Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add createReducer for redux #3210

Closed
lidoravitan opened this issue Nov 9, 2018 · 6 comments
Closed

add createReducer for redux #3210

lidoravitan opened this issue Nov 9, 2018 · 6 comments

Comments

@lidoravitan
Copy link

lidoravitan commented Nov 9, 2018

Motivation

as mention in docs: "since many people don't like switch statements, it's very common to use a function that creates a lookup table of action types to case functions. We'll use the createReducer function described in Reducing Boilerplate." reference

I suggest to add createReducer for redux, it very common usage and it leads developers to implement redux with better good practice. sure we also need to add for documentation.
it pretty same as combineReducer utils that is common usage, and redux expose that helper.

Benefits

  • Reducing Boilerplate
  • Leads developers for good practice
  • Not need to declare this methods for each project as utils or install another package only for createReducer method.

what are you thinking ?

@timdorr
Copy link
Member

timdorr commented Nov 9, 2018

Reducers are just a pure function that takes state and an account and returns the new state. Many are implemented as switch statements, but they aren't necessary to every implementation. So, making that part of the default library is a bit too prescriptive.

However, we are looking into boilerplate reduction and other tooling to get users started quickly here: #2859

@timdorr timdorr closed this as completed Nov 9, 2018
@markerikson
Copy link
Contributor

More specifically, we've already added this to our new https://github.com/reduxjs/redux-starter-kit package. Our version also uses Immer internally to allow users to simplify their immutable update logic considerably. Try it out!

@lidoravitan
Copy link
Author

@markerikson yeah cool I found it! it perfect, thanks!.

@lidoravitan
Copy link
Author

@markerikson do you know if you are planning to add tests coverage to reduxjs/redux-starter-kit ?
I defiantly excited to contribute and help to improve this package.

@markerikson
Copy link
Contributor

Looks like we've got a few tests in there, but there might be some more that could help. Also see the list of open issues.

@lidoravitan
Copy link
Author

Cool thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants