-
Notifications
You must be signed in to change notification settings - Fork 67
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
Disable the state-changed event when not needed #127
Comments
@tur-nr I can take a look at it and propose a PR on the weekend. Let's see how this looks when implemented. |
|
I think this is down to the use of the library. You should be using higher order elements that make use of the Mixin and then pass the properties down. I don't like the idea of opting out of events, it's in the developers hands not to use the Mixin for every component that needs state. This is more beneficial for your application as it decouples your elements from Redux and makes them more portal. |
@tur-nr I agree. Thus the question if all 20 components really need this. |
I have a lot of different components that do different things on the data in the state by using reselect and I need the Redux store for using selectors. That's why I add the But even if I would optimize this: My app gets new components every month and they all need their own space in the state. I agree that changing polymer-redux might be a bit too much. Proposal
|
@tur-nr I was wondering: Why do we even need the |
In case a developer wants to subscribe to state changes to perform logic outside of bindings. Much like the |
I think the resulting flexibility is beneficial for developers. |
Every time the state is changing, the "state-changed" event is dispatched onto every element that is using the ReduxMixin. So the more elements I have, the more events are dispatched, even when I don't want to listen to them at all.
But why is this a problem? This behaviour is increasing the scripting time at least 25% (up to 50% max), which is slowing down the overall performance. It even gets worse when using requestAnimationFrame.
Proposal
Make the "state-changed" event optional:
When creating the mixin:
And in the redux listener:
Of course I could extend the mixin and make my changes, but as this is something that also might affect others I think this should be part of PolymerRedux itself.
Additional info
The text was updated successfully, but these errors were encountered: