Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Good practice in updating the collections #284

Closed
BajakiGabesz opened this issue Mar 26, 2021 · 3 comments
Closed

Good practice in updating the collections #284

BajakiGabesz opened this issue Mar 26, 2021 · 3 comments

Comments

@BajakiGabesz
Copy link
Contributor

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
Copy link
Owner

dsuryd commented Mar 26, 2021

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
Copy link
Contributor Author

Sure. :)

BajakiGabesz added a commit to BajakiGabesz/dotNetify that referenced this issue Mar 30, 2021
…he necessary properties when there's a real change.
BajakiGabesz added a commit to BajakiGabesz/dotNetify that referenced this issue Mar 30, 2021
BajakiGabesz added a commit to BajakiGabesz/dotNetify that referenced this issue Mar 30, 2021
…he necessary properties when there's a real change.

(cherry picked from commit fd0ef5d)
BajakiGabesz added a commit to BajakiGabesz/dotNetify that referenced this issue Mar 30, 2021
dsuryd added a commit that referenced this issue Apr 1, 2021
@BajakiGabesz
Copy link
Contributor Author

Thanks for your merge! I close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants