packages/core/incremental-grouping.md
n items.Example:
Items: A, Aa, B, Ba, Bb, C, Ca, Cb, Cc, Cd Batch size: 2
Batch 1: [A, Aa] Grouped: [A, [A, Aa]]
Batch 2: [B, Ba] Grouped: [B, [B, Ba]]
Merged: [A, [A, Aa], B, [B, Ba]]
Batch 3: [Bb, C] Grouped: [B, [Bb], C, [C]]
Merged: [A, [A, Aa], B, [B, Ba, Bb], C, [C]]
This is a simple incremental grouping. However, what we require is windowed grouping.
Windowed grouping means that we only keep n number of items in memory at any point in time.
As the user scrolls up & down, we fetch only the batch that is needed for rendering the items
in the current window.
Requirements:
Approach:
n items.Questions:
The naive but stable approach would be to refetch everything and recalculate the current batch. Another approach would be to diff the new & old set of IDs and determine which batches have changed.
We can then reload the batches only if they are currently cached, otherwise do nothing.
The core module will only manage the cache. It will also be responsible for loading the appropriate batch based on if the item is found in the cache or not. This should be automatic for maximum optimization opportunities.