News for hackers. Stuff that matters.
Re:A SoundCloud client in React and Redux by babbeloski on Sunday June 12, 2016 @06:41PM (#11890682)
At work I've started keeping the reducer in the actions file, anyone else do that? This way they can share the same const declarations, and you don't have to toggle between two files when most actions / reducers are pretty small.
Re:A SoundCloud client in React and Redux by tacone on Sunday June 12, 2016 @06:57PM (#11890734)
Of course: https://github.com/erikras/ducks-modular-redux

The potential reason not to do that is that more than a reducer may listen for a given action, even though I guess it's more an exception than the norm.

Re:A SoundCloud client in React and Redux by tfb on Sunday June 12, 2016 @08:09PM (#11890973)
https://github.com/loggur/react-redux-provide

This allows you to encapsulate all of your Redux actions/reducers/etc into standalone "providers". It decouples pretty much all of your React components (UI) from your Redux logic (models/controllers), which maximually separates your concerns and makes it trivial to reuse anything anywhere. It also allows you to instantly swap databases and/or websocket implementations.

Re:A SoundCloud client in React and Redux by kumaraman on Sunday June 12, 2016 @07:18PM (#11890812)
I originally tried this but then discovered combineReducers() this will allow you to organise your reducers into a single import. I found it a more sane way to organise all of my reducers, as the majority of them were small. Here's a link for API http://redux.js.org/docs/api/combineReducers.html
Re:A SoundCloud client in React and Redux by jamra on Sunday June 12, 2016 @07:25PM (#11890842)
That would combine your reducers into one. I believe he was referring to putting action creators in the same file as their associated reducers.
Re:A SoundCloud client in React and Redux by clarus on Monday June 13, 2016 @01:48AM (#11891921)
It seems that this is also the way of doing things in Elm (from which Redux is inspired): http://guide.elm-lang.org/architecture/index.html . The Update part groups both the definition of the actions and the reducers.
Re:A SoundCloud client in React and Redux by tokenizerrr on Sunday June 12, 2016 @06:51PM (#11890715)
I started doing that pretty soon after starting with Redux, with some other tweaks to make them even more tightly coupled. It worked well for me, but I assume there is a reason not do that. However, I never figured that one out.
Re:A SoundCloud client in React and Redux by rattray on Sunday June 12, 2016 @07:18PM (#11890814)
I do this as well in small projects, then split it out when things get big (eg; >1000 line file).