dsuryd / dotNetify

Simple, lightweight, yet powerful way to build real-time web apps.
https://dotnetify.net
Other
1.17k stars 164 forks source link

Good practice in updating the collections #284

Closed BajakiGabesz closed 3 years ago

BajakiGabesz commented 3 years ago

Hi, It was a great pleasure to find dotNetify, it makes my life easier and I'm going to create a Xamarin application based on this, but I was faced with an issue and maybe I made something wrong. So, anytime I just want to update a list item, on the screen the whole object updates, for example, I have a model with properties like Id, Name, ImageUrl, Description, inherited from ObservableObject. It works fine, but a list element has been changed, even if it's only one property the whole item updates because in the ViewState.cs just removes and inserts the item in this case, which I think not the best efficient way to do: _dispatcher.InvokeAsync(() => { listIface.Insert(i, newItem); listIface.RemoveAt(i + 1); }); I think it could be better if we can use Reflection here to only update properties which have been changed.

I just update the list in a next way: this.UpdateList(nameof(FeaturedStories), GetNewsItem());

Am I able to get the information about the real changes or should I write it by myself?

dsuryd commented 3 years ago

Hi, I agree that the update list logic in ViewState.cs could be improved. Would you like to take a stab at it and then send me a PR?

BajakiGabesz commented 3 years ago

Sure. :)

BajakiGabesz commented 3 years ago

Thanks for your merge! I close this issue.