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

Redux: The Reducer Function

Redux: The Reducer Function

1:54
There is something in common between all Redux applications. They have to implement the reducer: a function that calculates the next state tree based on the previous state tree and the action being dispatched. We are presenting a “complete” example in the code window below. Feel free to click around and explore! We will be explaining what everything does during this course.
Watch this lesson now
Avatar
egghead.io

There is something in common between all Redux applications. They have to implement the reducer: a function that calculates the next state tree based on the previous state tree and the action being dispatched.

We are presenting a “complete” example in the code window below. Feel free to click around and explore! We will be explaining what everything does during this course.

Avatar
Elia

Supposing to have a complex state like Clients and Invoices.
Every list page is paginated, so i don't store all the state of Clients and Invoices, but only what is shown in current page.
I also need to store the current invoice or client when is edited. Because a user can edit a client that is not shown in the index page (simply entering the id in url).
Accordingly with this, is correct this state? Or there is a better way to store something like that?

Invoices {
list: [
{
_uid: 1,
date: '2016-02-10'
},
{
_uid: 2,
date: '2016-02-09'
}
],
pagination: {
currentPage: 1,
items: 10,
count: 100
},
current: {
_uid: 1,
date: '2016-02-10'
}
},
Clients {
list: [
{
_uid: 98,
name: 'John'
},
{
_uid: 99,
name: 'Sam'
}
],
pagination: {
currentPage: 10,
items: 10,
count: 100
},
current: {
_uid: 1,
name: 'John'
}
}

Avatar

Looks like jsbin is not properly running the examples.

Avatar
Christopher

I've found all Dan's videos in this series really clear, comprehensive, and extremely helpful in learning Redux. I particularly love this one though because, to me, it sounds like the narration from a movie trailer or opening theme to a TV show - the way he spends the whole video describing a reducer function only to tell you that it's called a reducer function at the very end. It feels like The Reducer should be a movie starring Denzel Washington or Liam Neeson in the vein of The Equalizer. (To be read like the Six Million Dollar Man intro) "Application state - data in memory - a collection barely manageable. Gentlemen, we can refactor it. We have the technology. State will be better, stronger, faster!"

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?