RealmResults with change listener clarification

405 views
Skip to first unread message

Bryan Madaras

unread,
Oct 27, 2015, 3:36:22 PM10/27/15
to Realm Java
I just want to confirm that I am reading the docs right as this would be hugely helpful.
When a RealmChangeListener is added to a RealmResults it will only be triggered when updates are made to the realm instance that change the outcome of the RealmQuery that created the RealmResults.


I believe in previous versions there was no way for me to know if updates had occurred against a model type that I was interested in, so I was interested in updates to the User model but updates to the Contact model would also trigger the change listener because the Contact and User models were in the same realm.

Christian Melchior

unread,
Oct 28, 2015, 6:02:47 AM10/28/15
to Bryan Madaras, realm...@googlegroups.com
Hi Bryan

You are partly right and partly wrong. We added RealmChangeListeners to RealmResults in in 0.84.0, to be able to support callbacks from the async query methods. So while they ideally will only trigger when changes happened to data inside the RealmResults that is still not entirely true, they will actually trigger if some other data changed as well

So in your example if you have a RealmResult with Users, it will still get notified if you changed some Contacts. This is ofcourse not ideal as it cause the app to do more work than was actually needed, but tis will however be fixed when we implement fine-grained notifications which are tracked here: https://github.com/realm/realm-java/issues/989.

I hope that answers your question.

Best,

--
Christian Melchior
Senior Android Developer


--
You received this message because you are subscribed to the Google Groups "Realm Java" group.
To unsubscribe from this group and stop receiving emails from it, send an email to realm-java+...@googlegroups.com.
To post to this group, send email to realm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/realm-java/fe358983-b472-4de8-8d83-25864f50af13%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



{#HS:133760656-2150#}

Bryan Madaras

unread,
Oct 28, 2015, 9:33:00 AM10/28/15
to Realm Java, bryan....@gmail.com, he...@realm.io
Thanks for the clarification I will be keeping an eye on that issue.
-Bryan
Reply all
Reply to author
Forward
0 new messages