在React Native和Android之间共享Realm实例 [英] Sharing Realm instance between React Native and Android

查看:131
本文介绍了在React Native和Android之间共享Realm实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个将Realm用于React Native的React Native项目. 它可以正常工作,但是现在,我面临编写使用相同Realm实例的Android Service的问题.有可能吗,我该怎么办?

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?

推荐答案

我认为您可以通过

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.

否则, Realm for Android对非加密的多进程支持领域将进入Realm-Java 2.0.0 (该部分实际上在快照的 in 中),这无疑将支持该用例.当Realm-React-Native(当前是1.5.0)和Realm-Java(以前是1.5.1,现在是2.0.0-rc4)的核心版本相同时(2.0.0).

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.

根据 https://github.com/realm/realm-js/issues/984#issuecomment-297716769 为应用可靠地获得相同内核以及同步和对象存储版本的唯一方法是,如果您从头开始构建Realm-JS和Realm-Java并使用像这样在您的应用程序中.

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.

这篇关于在React Native和Android之间共享Realm实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆