http://github.com/redux-effects/redux-effects
Which makes it dead simple to write universal apps and keep all your functions pure. Would love to get some feedback on it from people who are into this stuff.
1. Splitting folders entrypoints — very nice idea! For now i feel it a bit cryptic.
2. Router is the thing we want to tinker with. Gonna give a look into your solution.
3. At first we had all API interactions in separate folder, and truth to be told it was not very handy. That always felt like one more file to keep track of. Maybe our current design is a a flaw. Open question.
4. We do have one! (checkout .eslintrc) I feel like it is actually even more 'strict' than default Airbnb's one.
The common pattern I've seen is:
- Dispatch simple actions that contains 'just' a URL
- Have a middleware to take those actions, make the API call (based on the URL in the action), and then dispatch further progress, success and/or failure actions
- Receive the API data in your reducer and transform it before adding it to your store.
That's a pattern that works really nicely and is crazy easy to write tests for.
> 4. We do have one! (checkout .eslintrc) I feel like it is actually even more 'strict' than default Airbnb's one.
Oops sorry!
PS You are also welcome to PR =)
I was really excited that you found a way to return proper 404's! https://github.com/GetExpert/redux-blog-example/blob/master/...
There are a few things I would have done differently though. Check out:
- this sample project I made. it's not ideal though and I have learnt a since I made this, but it has a few good ideas https://github.com/joshhunt/reactapus
- the official 'real world' example https://github.com/rackt/redux/tree/master/examples/real-wor...
Suggestions:
- Consider putting client, server, and universal code into seperate folders like in my example - it makes it easier to understand what code is executing where.
- Move routing into a 'universalRouter.js' which is the one place that performs routing and returns the root component. Both the server and client use this. https://github.com/joshhunt/reactapus/blob/master/src/app/un...
- Actions should be very simple, return basic serialisable objects, and be super easy to test. Don't make API calls directly in actions. Redux has fantastic middleware to make this easier for you. I do it in a basic way in my sample project, but the redux real-world example does it much better. Check out https://github.com/rackt/redux/blob/master/examples/real-wor...
- Consider using ESLint. Airbnb has a premade config that does a pretty good job of providing best practices. https://github.com/airbnb/javascript/tree/master/linters Beware, it's going to flag a whole bunch of stuff in you project, but you'll get much better code out of it.