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

Look at the thunks and potentially rework them a bit #19

Open
tomRedox opened this issue Mar 10, 2016 · 0 comments
Open

Look at the thunks and potentially rework them a bit #19

tomRedox opened this issue Mar 10, 2016 · 0 comments

Comments

@tomRedox
Copy link
Owner

As per meteor/guide#263 (comment), @ffxsam said:

I only took a quick glance, but I would make a few suggestions with regards to conventions/syntax.

For thunks, IMO it's best to have a pattern like this:

Thunk: USER_REQUEST_[action name]
Succeed: USER_[action name]SUCCEEDED
Failed: USER
[action name]_FAILED
Also, I might have missed something (likely, since I didn't look in detail), but I'm not sure why you're using thunks this way:

https://github.com/tomRedox/simpleCRM/blob/master/imports/ui/redux/customer-list-actions.jsx

.. when there's no async actions being performed?

He gives a great explanation and example of how to do thunks here:
https://github.com/ffxsam/ffx-meteor-react-boilerplate/blob/example/client/actions/colors.js

I had originally done the thunks like that following @gaearon's examples here https://github.com/reactjs/redux/blob/master/examples/shopping-cart/actions/index.js. He appears to be using that syntax despite not all of the code wrapped being async, I guess maybe he's doing that for consistency and to allow for async or additional stages later.

What had led me to the shopping cart example in the first place was the need to access the state in my actions and so i needed the getState property. I think I thought that I had to format my thunks like that to get it, but that may not be the case.

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

No branches or pull requests

1 participant