hexatile tileCount() stays 0 — computed never sees Map mutations #1030

Closed
opened 2026-08-13 04:47:19 +00:00 by spikerj · 1 comment
Owner

Found during Wave 7 coverage (agent a8) while unit-testing HexatileGameComponent with a mocked WebGLRenderer.

tileCount is a computed over a plain Map:

tileCount = computed(() => this.hexTiles.size);

hexTiles is filled in generateHexGrid() (AfterViewInit / GLB load). The computed has no signal dependencies, so the first CD caches 0 and the inventory footer {{ tileCount() }} never updates after the grid exists (331 tiles for gridSize = 10).

getExportData() reads the Map directly and is fine; only the HUD count is wrong.

Fix: store the count in a signal updated at the end of generateHexGrid / clearGrid, or replace hexTiles with a signal-backed structure.

Characterization test: hexatile-game.logic.spec.ts asserts tileCount() === 0 while hexTiles.size > 100.

Found during Wave 7 coverage (agent a8) while unit-testing `HexatileGameComponent` with a mocked WebGLRenderer. `tileCount` is a computed over a plain `Map`: ```ts tileCount = computed(() => this.hexTiles.size); ``` `hexTiles` is filled in `generateHexGrid()` (AfterViewInit / GLB load). The computed has **no signal dependencies**, so the first CD caches `0` and the inventory footer `{{ tileCount() }}` never updates after the grid exists (331 tiles for `gridSize = 10`). `getExportData()` reads the Map directly and is fine; only the HUD count is wrong. Fix: store the count in a signal updated at the end of `generateHexGrid` / `clearGrid`, or replace `hexTiles` with a signal-backed structure. Characterization test: `hexatile-game.logic.spec.ts` asserts `tileCount() === 0` while `hexTiles.size > 100`.
Author
Owner

Resolved in spikersoft-angular PR #819 (merged to master). hexatile tileCount() recomputes when the Map mutates. Closing.

Resolved in spikersoft-angular [PR #819](https://git.spikersoft.com/spikerj/spikersoft-angular/pulls/819) (merged to `master`). hexatile tileCount() recomputes when the Map mutates. Closing.
Sign in to join this conversation.