-
-
Notifications
You must be signed in to change notification settings - Fork 419
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
Are action creators legacy? #68
Comments
Definitely some cool ideas here! @ShMcK Perhaps we could provide the flexibility for both. By default, create the action creators on start up, but also have options to change that behavior. Maybe two options like this:
init({ lazyActionCreators: true })
model({
lazyActionCreators: true,
name: 'count',
...
}) |
Not a bad idea. But the slippery slope of configuration might be better avoided. I chatted with Scott today about this. I'll summarize the key points The ideal dispatch API should:
Probably the current API has the most hope and getting all three. |
Yup yup, agreed. And depending on your IDE, The autocomplete kinda works anyways. |
You and your amazing WebStorm. Anything else you'd like in an action? |
haha, yup, WebStorm makes me happy! Can't think of much else for now. Idea # 2 you mentioned above would be cool though! So far, my day to day use with mirror is pretty nice, so I'm happy so far with what we have! |
Dispatch is basically made of a bunch of action creators organized by model.
See createDispatcher
The current design potentially offers the following benefits
Idea 1: Hacky JavaScript ?
But if all action creators are all essentially the same code, is there a way to create action creators on the fly?
Although, I don't think the above would work dynamically,
Idea 2: Dispatch as a Function
it's possible to reference dispatches in a way that would work. Some examples:
This would call
dispatch['count']['addBy'](5)
. Boom.Or some variation of above.
The only benefit really being that you don't have to create action creators on startup, and hold them in memory through the life of the app. Note that this is what most standard redux apps do anyway, it just strikes me as wasteful.
I'm not sure how you would structure this if you were adding extra properties to the action, like "meta". But we don't currently handle any situations like that anyway.
Summary
Consider this more of a thought experiment than a proposal.
The text was updated successfully, but these errors were encountered: