perf(web): batch dashboard tile hydration
This commit is contained in:
parent
63b008095f
commit
de87464ef1
7 changed files with 518 additions and 40 deletions
|
|
@ -9,6 +9,7 @@ import {
|
|||
createDashboardTileBackoff,
|
||||
createDashboardRequestAborter,
|
||||
runDashboardHydrationQueue,
|
||||
runDashboardHydrationBatchQueue,
|
||||
runViewportAwareDashboardHydrationQueue,
|
||||
shouldPauseDashboardRefresh,
|
||||
splitDashboardHydrationItemsByVisibility,
|
||||
|
|
@ -121,6 +122,25 @@ describe("dashboard refresh lifecycle", () => {
|
|||
expect(maxActive).toBe(2);
|
||||
});
|
||||
|
||||
test("hydrates queued work in fixed-size batches", async () => {
|
||||
const batches: number[][] = [];
|
||||
|
||||
await runDashboardHydrationBatchQueue({
|
||||
batchSize: 3,
|
||||
hydrateBatch: (items) => {
|
||||
batches.push(items);
|
||||
},
|
||||
items: [1, 2, 3, 4, 5, 6, 7],
|
||||
signal: new AbortController().signal,
|
||||
});
|
||||
|
||||
expect(batches).toEqual([
|
||||
[1, 2, 3],
|
||||
[4, 5, 6],
|
||||
[7],
|
||||
]);
|
||||
});
|
||||
|
||||
test("hydrates visible items before deferred items and waits for idle", async () => {
|
||||
const calls: string[] = [];
|
||||
const idleReleases: Array<() => void> = [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue