I'm struggling best way of dealing with collection updates in Aurelia. Imagine that I have a view (list of news with comments) which is built using set of repeat.fors from following model:
var news = [
{
id: 1,
title: 'Some title',
comments : ['comment1']
},
{
id: 2,
title: 'Some title',
comments : ['comment1']
},
{
id: 3,
title: 'Some title',
comments : ['comment1']
}
];
I also have timer created using setInterval(), which fetches list of news every second. Now imagine that following list of news comes back:
var freshNews = [
{
id: 1,
title: 'Some title',
comments : ['comment1', 'comment2']
},
{
id: 2,
title: 'Some title',
comments : ['comment1']
}
];
If I use this freshNews list in my repeat.for it will rebuild whole DOM that display news causing flicker and data entered by user being lost (imagine that under each news is textarea for entering comments).
How do I work on this scenario? This works quite nicely in Angular thanks to it's dirty checking and way ngRepeat works (angular will not destroy DOM corresponding to object that hasn't changed), in React it will also work nice thanks to shadow DOM.
How do I deal with this scenario in Aurelia?