perf(14-03): add notification batching to queue store and granular change tracking to library store

- Queue store now uses queueMicrotask batching (matching library store pattern)
- Library store adds changeGeneration counter incremented only on actual data changes
- LibraryController checks changeGeneration before requestUpdate, skipping loading-only transitions
- Reduces unnecessary component re-renders during data loading cycles
This commit is contained in:
2026-03-14 13:53:59 -04:00
parent 1ec8f82ef8
commit d0c05dc1d4
3 changed files with 46 additions and 2 deletions
@@ -29,9 +29,21 @@ export class LibraryController implements ReactiveController {
// LIFECYCLE HOOKS
// ===================================================================
/** Last observed changeGeneration from the store. */
private lastChangeGen = libraryStore.changeGeneration;
hostConnected(): void {
this.lastChangeGen = libraryStore.changeGeneration;
this.unsubscribe = libraryStore.subscribe(() => {
this.host.requestUpdate();
const gen = libraryStore.changeGeneration;
// Skip requestUpdate when only loading flags toggled
// (changeGeneration unchanged means no actual data changed).
if (gen !== this.lastChangeGen) {
this.lastChangeGen = gen;
this.host.requestUpdate();
}
});
}