How are you passing your model to the rendering function in Html.Lazy without 
it triggering on other changes to the model? Does Html.Lazy not look for 
changes in the function itself and you just use a closure to pass the actual 
model value? That would seem like a bug in Html.Lazy if it did so though you 
would be making it a useful bug.

More technically, as with any other function, the results of Html.Lazy 
functions can (or at least should) only depend on their inputs. Lazy nodes in 
the rendering graph reuse the previous rendering if their inputs haven't 
changed (based on a shallow comparison) and otherwise re-render. You need to 
pass the model to the lazy node in order to have something to render and if the 
model is experiencing shallow changes — e.g., because a non-change may still 
rebuild parts of the model — that should result in re-rendering.

Mark

P.S. I do wonder whether it would be useful to have a deep lazy equivalent that 
would perform a deeper comparison to see whether it could avoid re-rendering. 
As with the existing lazy implementation, it wouldn't need to be "perfect" — 
for example functions might only be subject to shallow comparisons — but 
looking more deeply into the inputs would allow for more rendering patterns in 
which a collection of parameters are collected into a record that might get 
rebuilt on every rendering pass.

> On Feb 8, 2017, at 8:01 AM, 'Rupert Smith' via Elm Discuss 
> <[email protected]> wrote:
> 
>> On Wednesday, February 8, 2017 at 12:43:26 PM UTC, Julian wrote:
>> Any idea if this is expected behavior? Or is this a bug with the virtual dom 
>> code?
> 
> Have you tried Html.Lazy? It performs an extra check on the model to see if 
> it has changed (by reference comparison):
> 
> http://package.elm-lang.org/packages/elm-lang/html/2.0.0/Html-Lazy 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to