Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharing Realm instance between React Native and Android

I'm working on a React Native project that uses Realm for React Native. It works without problems but now, I am faced with a problem of writing Android Service that would use the same Realm instance. Is it possible and how would I do that?

like image 805
Maciej Grycz Avatar asked Oct 30 '22 20:10

Maciej Grycz


1 Answers

I think you can communicate from Java to React Native through Native Modules and do your Realm-related code in Javascript as you normally would.

Otherwise, Realm for Android's multi-process support for non-encrypted Realms will arrive in Realm-Java 2.0.0 (and that part is actually in with the snapshot), which will most definitely support this use-case; when the core version of Realm-React-Native (currently 1.5.0) and Realm-Java (previously 1.5.1, now 2.0.0-rc4) will be the same (2.0.0).

So not yet, but actually quite soon. I'd estimate a month or two at most from the time of writing.


EDIT: According to https://github.com/realm/realm-js/issues/984#issuecomment-297716769 the only way to get the same core and sync and object-store versions reliably for your app is if you build Realm-JS and Realm-Java from scratch and use them in your application like that.

like image 109
EpicPandaForce Avatar answered Nov 02 '22 22:11

EpicPandaForce