dadhi / XamlTea

The Elm Architecture for building .NET UI applications: WPF and more
MIT License
13 stars 1 forks source link

Consider caching the component UI for the Model #4

Open dadhi opened 6 years ago

dadhi commented 6 years ago

We may hold the cache of UI identified by Model, may be with Model key for easy lookup. Then the IComponent.View may lookup for the cached UI if the Model did not change.

Naive question, what if we just added new UI to container, can we just reuse the rest of the container to minimize allocations? UI tree is immutable. What if we pass previous UI to View?

UI View(UI old, Model model) { .. }

May be it defeats the whole purpose of the model projection to view. Then the virtual UI Diff + Caching should be smart enough to do minimum allocations and do a fast real UI patching.