The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

## Redux: Implementing combineReducers() from Scratch

#### Redux: Implementing combineReducers() from Scratch

4:22
Learn how to build a reasonable approximation of the combineReducers() utility in 15 lines. No magic!
Watch this lesson now

Learn how to build a reasonable approximation of the combineReducers() utility in 15 lines. No magic!

Sequoia McDowell

I love that you explained what `combineReducers` does long-hand (writing it out explicitly) in the last video before introducing it here. That took the magic out of it and made it really easy to understand what's going on. Kudos!

mobility-team

Great explanation, great content!

Enrique

That was so meta, it made me go `O_o`

Am I correct in saying the following:

Every event is dispatched to all of the reducers in combined reducers. If the action.type doesn't exist in the reducer it doesn't happen.

Or

If I wanted to have two different things happen with the same action, I can have to separate updates happen to the state. Let's say I am rolling the dice and tracking all rolls of the dice, I might keep a currentRoll running for display and a rollHistory for a fairness tracker. Since all actions pass through all reducers, I don't need to worry about managing which reducer is getting the action.

The more I look at this the more brilliant it is. The problem is attempting to pass it on to the next person.

I once got into an argument with someone about the ability of javascript to do multi dimensional arrays. He was fixated on the form array[ ][ ][ ][ ]. From what I can tell, he is correct that javascript doesn't do that. What is the difference between that and array[ { [ { [ ] } ] } ] and array [ ] [ ] [ ] [ ]. I think there are many differences. The question is, can I make the first one accomplish the tasks that the second one use to do. If n is small, it isn't that terrible. When n starts getting big, n^2 starts beating me up. But for most of the times I have run into multiple dimensions on arrays, the j, k and l usually stay small.

That is me attempting to say that communicating programming ideas to programmers can be challenging. Trying to communicate programming ideas to non programmers and have them actually hear what you said... That is how folks end up needing medication.

dan entous

noticed that using `combineReducers` “from scratch” vs redux has a slight observable difference:

• “from scratch” initialises by calling each reducer once
• redux initialises by calling each reducer twice
• then the `store.createStore( todoApp );` calls each reducer again, once

why is that?

HEY, QUICK QUESTION!