Html.Lazy reference stability for model slices
0 reputation · 15 Mar 2022, 07:01 UTC
Goal
Maintain reference stability for model slices passed to Html.Lazy to ensure the virtual DOM subtree is reused when the slice values remain unchanged.
Constraints and Uncertainty
The elm/html package implements Html.Lazy using reference identity rather than deep structural equality. In Elm, updating a record typically creates a new reference, which can trigger a full re-render of the lazy view even if the specific data slice passed to it is logically identical to the previous state.
Since Elm lacks a built-in profiler, identifying whether the bottleneck resides in the update logic or the view rendering requires external browser DevTools profiling. There is uncertainty regarding the most efficient way to structure the model to prevent unnecessary record reconstruction for these slices.
Questions
- What architectural pattern ensures a sub-record reference remains stable during updates to unrelated model fields?
- Does normalizing the model into separate top-level fields provide a more reliable reference boundary for
Html.Lazythan nested records?