There is a issue if use both realm-java and realm-js
See original GitHub issueIn my android app, I use both realm-java and realm-js. After I created a object in reaml-java, then I query it in react-native with realm-js, but I get null.
This is my code:
// create a Baby object
Realm realm = Realm.getDefaultInstance();
Baby baby = new Baby();
baby.name = "Baby Name";
realm.beginTransaction();
realm.copyToRealm(baby);
realm.commitTransaction();
// then query in react-native
let baby = realm.objects('Baby').filtered('name = "Baby Name"')[0];
// but the result of baby is undefined
It won’t get the result until I reload react-native JS. But I debug in chrome with stetho_realm, I can see the object has been created.
I don’t know whether it’s a bug, or maybe there is a error in my code. But that’s OK in my ios app with using both realm-swift and realm-js.
My environment are:
Mac OS 10.11 Android 5.1 node 5.3 realm-js 0.11.1 java version “1.8.0_66” io.realm:realm-gradle-plugin:0.88.2
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:10 (1 by maintainers)
Top Results From Across the Web
Will Realm-Java Support Realm-Core 12.11.0 in the near ...
Hello, The team that I work in is moving toward supporting react-native 0.70.0 in order to adopt the many benefits of the new...
Read more >Using shared Realm db between Android native code and ...
Both of them says its not possible unless you build both Realm Java and RealmJS from scratch. To check this, I created one...
Read more >Realistic Realm - lessons learned after using it for 1.5 years
Any realm object must both be inherited from RealmObject or implement the RealmModel marker interface and be marked with an @RealmClass ...
Read more >10.8.0 - realm - npm
There are 102 other projects in the npm registry using realm. ... versions of Realm. Currently we support React Native (both iOS &...
Read more >Realm JS: A Mobile Database That Runs Directly inside Phones
This project hosts the JavaScript versions of Realm. Currently we support React Native (both iOS & Android), Node.js and Electron (on Windows, ...
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 FreeTop 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
Top GitHub Comments
FWIW, I found the following workaround to be effective:
io.realm.Realm.addChangeListener
orio.realm.DynamicRealm.addChangeListener
).write()
on the realm for it to update.I’m still getting this issue. I created a new React Native project and installed realm via npm (it installed version 1.12.0 of the realm npm module). On the Android side of things I’m using version 3.7.2 via the realm gradle plugin. I can add an object on the Android side of things but I only see an updated object count in RN if I use @wusuopu’s method of executing an empty write. The problem with that is that the count is alway one behind the actual count. I see this appears to be fixed so am wondering is there something I’m missing in order for my change listener to see changes made via Java?