RealmChangeListener on empty RealmResults never fires
See original GitHub issueGoal
Receive change updates on a RealmQuery
Expected Results
When the RealmQuery
changes, the RealmChangeListener
is fired
Actual Results
The RealmChangeListener
is never fired
Steps & Code to Reproduce
I create a query (realm.where(Test.class).findAll()
), and add a RealmChangeListener
to the returned RealmResults
(I maintain a strong reference to the RealmResults
).
If the query was empty when I made it, the RealmChangeListener
never fires, no matter how many times I insert an object that matches the query after that. If there is an object when the query is made, the the RealmChangeListener
does fire, even if all the objects are removed and then another one is inserted.
Version of Realm and tooling
Realm version(s): 3.3.1
Realm sync feature enabled: no
Android Studio version: 3.0 Canary 3
Which Android version and device: Pixel 7.1.2
Issue Analytics
- State:
- Created 6 years ago
- Comments:25 (13 by maintainers)
Top Results From Across the Web
Realm Change Listener with RealmResults not being called
You need to store the RealmResults as a field reference in order to ensure that Realm can update it RealmResults<Record> realmResults ...
Read more >RealmResults (Realm 6.0.0) - MongoDB
A RealmResults object cannot be passed between different threads. Notice that a RealmResults is never null not even in the case where it...
Read more >RealmResults (Realm 1.1.0)
A RealmResults object cannot be passed between different threads. Notice that a RealmResults is never null not even in the case where it...
Read more >Creating a Reactive Data Layer with Realm and RxJava2
RealmChangeListener <RealmResults<Task>> listener = new ... Of course, this is also why onCompleted() was never called - a listener doesn't ...
Read more >The things I've learned using Realm | by Gabor Varadi - Medium
And if you ever truly do need to swap out one implementation for the other, ... you receive a so-called RealmResults , which...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
See https://realm.io/docs/java/latest/api/io/realm/RealmResults.html
On top of that, you’re calling
copyFromRealm
instead of, like,copyToRealmOrUpdate
orinsertOrUpdate
or anything that actually writes into the db. Also, running synchronous transaction inside a change listener?Are you trying to get an infinite loop? 😕
What are you doing???
@kneth sorry I haven’t got a chance to try. Crazy sprints at work.