-
Notifications
You must be signed in to change notification settings - Fork 60
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 createAction #35
Add createAction #35
Conversation
The name referenced in the ticket bothers me because its a misnomer. The added function is not an action creator: it returns an action creator. A more appropriate name would be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should add documentation for this feature in docs/api-reference.md before submitting.
EDIT: Oh, my mistake, you already have that listed in your checklist before submitting :/.
lib/createAction.lua
Outdated
`createAction` provides a utility that makes action creation cleaner | ||
and less error prone. Define your Rodux action like this: | ||
|
||
return Action("MyAction", function(value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These comments need to be updated to reflect this API.
Right, I'd like to address the naming before getting too far into writing docs. Docs might also just mean transplanting a bunch of the comments into docs and thinning them out some in the actual code, as they're not as useful there. |
lib/createAction.lua
Outdated
The `type` field will be added automatically. Additionally, the returned action | ||
creator now has a 'name' property that can be checked by your reducer: | ||
|
||
local MyAction = require(Reducers.MyAction) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the convention to have this be require(Actions.MyAction)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'll have to update these, as well as the wording in the asserts.
1b71125
to
ae9899a
Compare
Having thought this over, I don't know if this approach is ubiquitous enough to justify this helper. Is this implementation too specific to exist as a general helper like |
Based on a renewed request in #31, we should pursue landing this. After thinking about it more, too, over the last... year and a half, this seems reasonable to me. |
return function() end | ||
end) | ||
|
||
expect(FooAction).to.throw() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect(FooAction).to.throw() | |
expect(FooAction).to.throw("must return a table") | |
nvm this is using a 3yr old version of test ez
Commenting here to allow actions to be executed (I believe that's how this works!) |
CLA Signature Action: Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you read and sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just by adding a comment to this pull request with this exact sentence:
By commenting with the above message you are agreeing to the terms of the CLA. Your account will be recorded as agreeing to our CLA so you don't need to sign it again for future contributions to our company's repositories. 0 out of 1 committers have signed the CLA.
|
CLA bot was confused by merges of existing master commits, so I rebuilt this on top of master to clarify. |
Closes #31.
Adds an implementation of the generic action creator... creator that's used commonly for Rodux projects within Roblox. Looking for feedback on a decent name for this.
Potentially compelling possibilities for names:
defineAction
ordefineActionCreator
makeActionCreator
(https://redux.js.org/recipes/reducingboilerplate#generating-action-creators)Checklist before submitting: