Maciej Grycz
Maciej Grycz

Reputation: 61

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?

Upvotes: 6

Views: 1142

Answers (1)

EpicPandaForce
EpicPandaForce

Reputation: 81539

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.

Upvotes: 2

Related Questions