-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize things a little bit #1
Conversation
This is freaking awesome. I can't wait to see the updated charts @mweststrate! |
Just wondering why you add a No doubt you are aware of this, I didn't understand it correctly I guess. |
@Kerumen you mean like in the original? For the first scenario (without selectors) |
@gaearon Could you update the unit tests too? I would like to see how you test stateless functional components! |
Well, it’s not that much of an improvement but it’s definitely better. Still can’t avoid going through 10K subscribers. There may be small things to optimize in React Redux as well so I’ll look there. I removed No, alas, I won’t be adding tests here, you should check out Redux repo (and open PRs to it) to see how to test components. |
I guess 10k subscribers is better than 10k items list reconciliation. But there are potential ways to avoid calling those 10k subscribers on every item change. Didn't have time to work on something concrete yet but it can be optimized further imho. See reduxjs/react-redux#269 |
Yeah, there are definitely ways to solve this even with vanilla Redux. The goal here is to avoid complicating the code beyond recognition 🙂 |
import React, { PropTypes } from 'react' | ||
import Header from '../components/Header' | ||
import MainSection from '../components/MainSection' | ||
import * as TodoActions from '../actions' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This TodoActions
import is useless here, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, missed this one. Doesn't affect the perf though.
Thanks for the contributions! Will re-run benchmarks tomorrow. |
I updated the code to be more idiomatic Redux. I think it performs a little better in my testing.
I might be able to take another look tomorrow evening in case there’s something else I could optimize.
The basic idea here (apart from minor refactorings) is to separate independently changing data (the list of items and items themselves). This, of course, highly depends on the specific app, which is why we don’t have a proper guide for doing it, but the point is that it’s usually possible to optimize an app for specific use cases if there is a need for it.
Computing Derived Data is probably the best we have in terms of guides on how to do it, but it definitely could use some state structure refactoring advice content.
cc @ellbee for no specific reason—just in case he’s interested