News for hackers. Stuff that matters.
Re:Redux Blog Example by madeofpalk on Friday September 11, 2015 @08:08PM (#10206778)
Nice. I love Redux + React so much, so I appreciate any effort into making people more aware of it.

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.

Re:Redux Blog Example by darawk on Friday September 11, 2015 @09:04PM (#10206887)
FYI I've made a set of redux middleware for executing and composing effectful actions:

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.

Re:Redux Blog Example by olegakbarov on Saturday September 12, 2015 @10:05AM (#10208104)
Cool! i'll take a look and let you know.
Re:Redux Blog Example by olegakbarov on Saturday September 12, 2015 @07:28AM (#10207820)
Awesome to hear that you found it useful.

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.

Re:Redux Blog Example by madeofpalk on Saturday September 12, 2015 @08:29AM (#10207907)
> 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.

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!

Re:Redux Blog Example by olegakbarov on Saturday September 12, 2015 @10:04AM (#10208101)
I should definitely take a closer look at this approach. Thank you.

PS You are also welcome to PR =)