In the case of a
List I would say there is a good chance that between views what is likely to happen is that a smaller number of items are added/removed to the list, and most of them stay the same. Since its the same item, it occupies the same memory. It would certainly be interesting and informative to make an example UI that does exactly this - and of course a variation that changes all the items in the list too (and compare the performance in both time and memory of that against just doing lazy against the whole list).
Either way, I think you are right, there are always going to be some pathological cases that make inserting
Html.lazy everywhere automatically not such a good idea.
Evan suggests adding
lazy to each item in long lists:
It can also be useful to use lazy in long lists of items. In the TodoMVC app, it is all about adding entries to your todo list. You could conceivably have hundreds of entries, but they change very infrequently. This is a great candidate for laziness! By switching
viewEntry entry to
lazy viewEntry entry we can skip a bunch of allocation that is very rarely useful. So the second tip is try to use lazy nodes on repeated structures where each individual item changes infrequently.
I think when you do that it’s also important to use
Html.Keyed.node for the list?
Thanks for the link to the guide, lots of stuff added since I last looked at it.
Html.keyed is described on the following page:
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.