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:
export default function PolymerRedux(store, mixinProperties = { enableStateChangedEvent: true }) {
And in the redux listener:
// Redux listener
const unsubscribe = store.subscribe(() => {
const detail = store.getState();
update(detail);
if (mixinProperties.enableStateChangedEvent) {
element.dispatchEvent(new CustomEvent('state-changed', {detail}));
}
});
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
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