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

Confusing createAction #673

Closed
TeoTN opened this issue Jul 31, 2020 · 4 comments
Closed

Confusing createAction #673

TeoTN opened this issue Jul 31, 2020 · 4 comments

Comments

@TeoTN
Copy link

TeoTN commented Jul 31, 2020

Hey,

I'd like to point out that for people with little or no former Redux experience, who jump straight into the toolkit, the createAction name is confusing. This function does not in fact create any action - it defines an action creator, which in turn is responsible for creating the action. I'd like to propose renaming createAction to defineActionCreator.

@markerikson
Copy link
Collaborator

Agreed that the name isn't 100% descriptive, but it's wayyyy too late to change that at this point.

Besides, most people won't even call createAction themselves - they just use createSlice.

@TeoTN
Copy link
Author

TeoTN commented Aug 2, 2020

No wonder Redux has such attrition at the moment... If one of the main libraries is openly confusing and contributors don't care about that at all

@markerikson
Copy link
Collaborator

I'll have to disagree with all of that statement.

RTK's usage is rising steadily (ignore the weird blip at the end, NPM's stats had 0 on Thursday and double on Friday):

https://npm-stat.com/charts.html?package=%40reduxjs%2Ftoolkit&from=2020-02-01&to=2020-08-02

No one else has raised a complaint about the naming of createAction. Besides, there's plenty of precedent for this name in the ecosystem, such as the redux-actions lib: https://redux-actions.js.org/api/createaction .

Also, renaming stuff would require:

  • Releasing a new major version
  • Breaking existing user code
  • Rewriting large portions of the docs and tutorials

All for no real meaningful benefit to the end user, and as I said, it's an API that most users won't even call themselves in practice.

I care deeply about our userbase. But, being a maintainer means weighing lots of different concerns: naming, API design, existing users, and much more.

As an example, see the multiple 250+ comment issue threads on how we designed the React-Redux hooks API:

I'm not going to publish a breaking change and force our users to rewrite their code, for a name change that I don't even feel is an actual improvement, and that has no further evidence that this is actually a problem for our users.

@phryneas
Copy link
Member

phryneas commented Aug 2, 2020

No wonder Redux has such attrition at the moment... If one of the main libraries is openly confusing and contributors don't care about that at all

Now go to the React repository and suggest they change they rename one of the core APIs. Go to TC39 and request that a JavaScript API is should be renamed. Because there is a more fitting name for it.
Even if you were right and there were a better name (personally, my take is that createActionCreator would be more fitting, but also too long and most developers would prefer createAction as a consequence), you would get the same answer: "it's too late for that".
And in both cases, it would be that answer because the maintainers are responsible.

RTK was in a public pre-release state for over a year. That feedback would have been possbile then. By now, it's in production for almost a year. It has a userbase. Numerous tutorials have been written on it.

It's not worth breaking something like that just to "be more precise". Guess what? There's a documentation.
I sincerely hope that people read the documentation for any package instead of guessing from the method names what arguments and return values a random method in there would have and how it should be used.

@reduxjs reduxjs locked as resolved and limited conversation to collaborators Aug 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants