-
Notifications
You must be signed in to change notification settings - Fork 167
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
[Bug]: NotifyCollectionChangedAction.Replace and Reset is not fired on RealmCollection #2854
Comments
Thanks for the repro! While we don't guarantee 100% identical behavior with |
Thanks. @papafe I've also noticed, that if i manually trigger realm.Write(() => colllection.Items.Add(item2)); // Add items
realm.Write(() => colllection.Items.Move(item1, 2)); // Move items
realm.Write(() => colllection.Items.Remove(item0)); // Remove items
realm.Write(() => colllection.Items[1] = item2); // Replace items (don't work)
realm.Refresh(); // NEW CODE COMPARING TO SNIPPET - does nothing
realm.Write(() => colllection.Items.Clear()); // Reset items (after realm.Refresh(), generates new remove action)
realm.Refresh(); // NEW CODE COMPARING TO SNIPPET - adds new "remove" action Output: Actions for ObservableCollection: Add, Move, Remove, Replace, Reset
Actions for RealmCollection: Add, Move, Remove, Remove ^Thats extra For me right now the missing |
@PawKanarek I managed to reproduce the issue, thanks a lot for your detailed example! I just had to copy paste 😄 Regarding your main issue, the main problem here is that we do not raise the Regarding the behaviour you've noticed in the second message, that is expected. There are actually two things happening here:
|
We can probably special case the situation where the collection count is 0 and raise |
Thanks for investigating so fast :) Yes, i also think that |
What happened?
Hi, I've noticed a bug where RealmCollection doesn't behave in the same way as ObservableCollection.
From what I've observed, RealmCollection doesn't fire
Replace
&Reset
from INotifyCollectionChanged Interface, thus my app is not updating the UI correctly when I switched from ObservableCollection to RealmDb in my ViewModels. I've made a very simple example to prove my point.Repro steps
Launch provided code snippet in console application.
Version
net5.0 for console app & Xamarin for my main project issue
What SDK flavour are you using?
Local Database only
What type of application is this?
Xamarin
Client OS and version
Android, iOS, ConsoleApp in .net core Console app for macOS
Code snippets
Relevant log output
^ ObservableCollection & RealmCollection should fire INotifyCollectionChanged events in the same way
The text was updated successfully, but these errors were encountered: