-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Finegrained notifications #989
Comments
Hi @Trikke |
Hi @cmelchior Will this enhancement also include some sort of support for adding RealmChangeListeners to RealmResults<> as well and get notifications when a RealmObject referenced by the RealmResults<> gets updated? This would be a very useful feature and would surely improve the performance of RealmBaseAdapter. Thanks in advance, PS. Is there a roadmap or expected release date for this feature? |
+1 |
1 similar comment
+1 |
I'm also anxiously awaiting this feature. In my opinion, this is definitely one of the features that needs to be implemented before a 1.0 release! |
I'm also excited with this feature 👍 Btw @feugatos, can you explain what you mean by this?
|
Comments from #1378 by mshusek. When we use RecyclerView or we want reload view under certain conditions default onChange is not sufficient. Now, in RecyclerView we have to reload visible rows so it is not a optimal solution. Moreover, we can not use animation when item is delete or insert to our model. I think better sollution will be implementing something like that:
|
Another +1 for have this feature implemented. |
Work-in-progress API proposal: Design criteria:
Open questions
|
@cmelchior Any use case for "Should closing a Realm trigger a onChange?" |
Yes, like removing references to objects that would otherwise crash or to reset UI state. |
@cmelchior Whether you can provide database changes, tell me which table changed。 RealmChangeListener listener = new RealmChangeListener() {
@Override
public void onChange(Class changeClass) {
// change detected
}
} |
Yes, I would definitely like to see a way to catch changes to specific classes of objects. However, I'm not sure about the exact signature from @yaming116 . What happens when a single transaction changes multiple classes? Would we get several simultaneous onChange() calls? Maybe, if this approach was used, it could be a Class[] or something to allow for a single invocation. Of course, the desired behaviour could be synthesized using the query results change listener but that seems a bit hacky at first glance. Not sure in the long run. |
@waltarmour @cmelchior it could be something like this.
Or something much more precise, using PrimaryKey (but it may be too much):
With this one the RecyclerView animations should be easy. I don't know how it could work without a PrimaryKey. Also, don't use RealmList/RealmResult/RealmObject .addChangeListener(). Use realm.addChangeListener(RealmList/RealmResult/RealmObject, listener) instead and get the needed classes for the listener from the first parameter. |
@cmelchior Will something similar to Realm Xamarin Fine Notifications be implemented soon? Any ETA? That feature on Xamarin Platform is exactly the one needed. Right now updating the Recycler View and writing my own code for finding which row got updated is getting very cumbersome for me which is the reason I am looking to migrate to Realm. Do provide me with an ETA. Thanks! :) Edit: I just checked and all the other Realm platforms have the fine grained notifications except for Java. Hope it will be implemented soon. |
@cmelchior I mean this request is one of the most important reasons people use orms. It has been put up for one and a half year now. This is there in all the other platforms of Realm and it is the basic feature which should have been there before the release of v1.0 and now this library is in 2.2 I would prefer to know the ETA of this feature as this is why I want to use orm other than SQLite other wise I might use some other ORM. So, do comment if you can specify an ETA. |
@Sai-Teja that comment is responding to me, that "no, that is a different problem". Although I still think that might fix those issues in one go 👅 The object store integration is a complex thing. It will be done eventually. I am not actually working on it so I do not know the exact ETA. |
@Sai-Teja To my knowledge, no ORM provide fine-grained notifications to the level described in this issue. "Table"-based notifications (some object of type A changed) are supported by e.g SQLBrite (and possibly others), but Realm also has support for that. This issue is for tracking changes to collections (added/removed/moved) + changes to single objects (fields changed). If you are looking for support for that today, DiffUtil (https://developer.android.com/reference/android/support/v7/util/DiffUtil.html) can be used for the collection changes no matter what DB solution you use. Regarding ETA. All I can say is that we are working actively on this, but we don't have a timeline we can share yet. |
@cmelchior I just wanted to correct "no ORM provide fine-grained notifications to the level described in this issue" |
@cmelchior Realm Swift provides such fine-grained notifications on collections and on single objects via KVO: https://realm.io/docs/swift/latest/#notifications |
@evgeny-sureev Realm Java depends on #3834 to add fine-grained notifications |
Has an API been decided for this yet? Will it look something like ListUpdateCallback`? |
- Add RealmObservable and RealmCollectionObservable interfaces. - Enable detailed change information for RealmResults through OrderedCollectionChange interface. - Fix a bug in the ObserverPairList which could cause the removed listener gets called if it was removed during previous listener iteration. Fix #989
- Add RealmObservable and RealmCollectionObservable interfaces. - Enable detailed change information for RealmResults through OrderedCollectionChange interface. - Fix a bug in the ObserverPairList which could cause the removed listener gets called if it was removed during previous listener iteration. Fix #989
- Add RealmObservable and RealmCollectionObservable interfaces. - Enable detailed change information for RealmResults through OrderedCollectionChange interface. - Fix a bug in the ObserverPairList which could cause the removed listener gets called if it was removed during previous listener iteration. Fix #989
- Add RealmObservable and RealmCollectionObservable interfaces. - Enable detailed change information for RealmResults through OrderedCollectionChange interface. - Fix a bug in the ObserverPairList which could cause the removed listener gets called if it was removed during previous listener iteration. Fix #989
For anyone who may want to try this feature before we release it: The listeners on The next release won't have fine grained notification for the object level. That has been tracked by another issue #4101 . Feel free to open a new issue if you meet problems when trying it with snapshot. Thanks for all your patience. |
Hi Realm devs,
we now have the RealmChangeListener to listen for changes if some background thread updates the Realm instance, which is great. But i'd like to put a feature request forward for more fine grained control when a listener can be called. It would be nice if it were possible to add a RealmChangeListener that only fires if a certain class of RealmObject is updated.
The issue i have now is that i have multiple fragments for multiple classes of RealmObject (eg. RealmUser, RealmMessage, RealmBeer) open at once, then a background services updates one of the RealmUser instances. Now all the RealmChangeListener are fired, and all fragments are updated individually. While ideally only the one that deals with RealmUser should be updating.
The text was updated successfully, but these errors were encountered: