[ALOY-1328] Refactor data-binding to be incremental rather then reset
|Assignee||Feon Sua Xin Miao|
DescriptionWe should think about how we can refactor data-binding to be more efficient. *Current situation* * We add a single event listener to the collections
fetch destroy change add remove resetevents. * The event listener always regenerates the views for all models, remove the existing children and adds the newly generated views (for ListViews and some others it just overwrites). *Problems* Even if just a single attribute of a single model is changed: * It uses a lot of memory. * It crosses the bridge a lot of times. * It takes a long time as collections become bigger and the bound views more complex. * Resetting all children causes flickering and scroll position is lost. *Desired situation* * For the
addevent, only child views for the added model(s) are generated and added to the parent. * For the
changeevent, child views for just the changed model(s) are regenerated and the old ones replaced under the parent. ** Yes, it would be even better if we could just change the child view of the model *attribute* that was changed, but I don't think the complexity of the logic is worth going that far. * For the
removeevents, only child views for the destroyed model(s) are removed from the parent.