Sharing Realm instance between React Native and Android

落爺英雄遲暮 提交于 2019-12-10 10:22:00

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/39489065/sharing-realm-instance-between-react-native-and-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!