Currently I have a webworker producing data slices which I want to render.
It looks a bit like this:
// limit frontend updates to max 100 per second or min 1 per secondconst timer;const lastUpdate = Date.now();worker.onmessage = ({data}) => { clearTimeout(timer); const now = Date.now(); const update = () => { lastUpdate = now; setState('events', reconcile(data.evts)); }; if (now > lastUpdate + 1000) { update(); } else { setTimeout(update, 10); }};
// limit frontend updates to max 100 per second or min 1 per secondconst timer;const lastUpdate = Date.now();worker.onmessage = ({data}) => { clearTimeout(timer); const now = Date.now(); const update = () => { lastUpdate = now; setState('events', reconcile(data.evts)); }; if (now > lastUpdate + 1000) { update(); } else { setTimeout(update, 10); }};
The problem is, when I have a
<For each={state.events}>
<For each={state.events}>
somewhere, the whole loop keeps rerendering, even if only a few elements have been prepended (they always get prepended).
I thought of trying to specify the key in reconcile (the data itself doesn't change, just position in the array) but it is 2 levels deep. The events array is of type: