-
Notifications
You must be signed in to change notification settings - Fork 158
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
Detecting ISet<> and IList<> member changes #3308
Comments
I can't reproduce this. I've attached a trivial console app that adds and removes items from a list/set and I seem to be getting all property change notifications correctly. Regarding the interfaces - you're right, it may be a little confusing, but when designing the API, we wanted to use the system interfaces as much as possible so your models don't take a dependency on Realm beyond inheriting from the base class/adding the marker interface for codegen. This means that our collection types are less expressive than they could be. The underlying type that we use for Edit: re-reading your comment, it may seem I misunderstood the problem you're describing. Is the issue that we previously used to raise I can see that there's a "Data Binding" section at the bottom of the Sets docs page, but a similar section is missing on the Collections page. Is your suggestion that we add it there or do you have other ideas for how we could make it more obvious that collections emit notifications, even if the system interfaces don't communicate that? |
Thanks @nirinchev yes you are correct on all counts. It would be helpful if there was an example in the docs showing how to subscribe to |
Gotcha and I agree - the docs could be improved. I filed a docs ticket to improve this and will close this one as working as designed. |
## Pull Request Info ### Jira https://jira.mongodb.org/browse/DOCSP-29852 See also: realm/realm-dotnet#3308 ### Staged Changes https://docs-mongodbcom-staging.corp.mongodb.com/realm/docsworker-xlarge/docsp-29852/sdk/dotnet/model-data/data-types/collections/ (pruned) https://docs-mongodbcom-staging.corp.mongodb.com/realm/docsworker-xlarge/docsp-29852/sdk/dotnet/model-data/data-types/lists/ (new) https://docs-mongodbcom-staging.corp.mongodb.com/realm/docsworker-xlarge/docsp-29852/sdk/dotnet/model-data/data-types/dictionaries/#watching-for-changes (added section) https://docs-mongodbcom-staging.corp.mongodb.com/realm/docsworker-xlarge/docsp-29852/sdk/dotnet/model-data/data-types/sets/#watching-for-changes (added section)
What happened?
ISet<>
andIList<>
membership changes used to produce aPropertyChanged
notification. This no longer happens (as of about v10.20 ish, maybe earlier). This happens with both local and sync.The documentation pages ( https://www.mongodb.com/docs/realm/sdk/dotnet/model-data/data-types/collections/ and https://www.mongodb.com/docs/realm/sdk/dotnet/model-data/data-types/sets/ ) say fields of these collection types implement
INotifyCollectionChanged
. The C# properties, declared asISet<>
andIList<>
, do not actually include this interface. BUT fortunately, it does actually work, if the field is castas INotifyCollectionChanged
.Repro steps
RealmObject
with anISet<string>
orIList<string>
field.PropertyChanged
event listener.Version
10.21.1
What Atlas Services are you using?
Atlas Device Sync
What type of application is this?
WPF
Client OS and version
Windows 10 22H2 22621.1555
Code snippets
RealmTest.zip
Stacktrace of the exception/crash you're getting
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: