Giter Site home page Giter Site logo

Support react-native android about realm-js HOT 8 CLOSED

realm avatar realm commented on May 18, 2024
Support react-native android

from realm-js.

Comments (8)

alazier avatar alazier commented on May 18, 2024

Steps added to the first comment

from realm-js.

emanuelez avatar emanuelez commented on May 18, 2024

From what I can tell native modules on Android allow to use Java code, not C++ code. This probably means we will need to just define an API in Java that only includes native methods that are then implemented in the JNI level. It's an extra level of indirection... is this what was in your mind?

from realm-js.

alazier avatar alazier commented on May 18, 2024

That's pretty much what I was thinking. The tricky part will be having our c++ objects communicate with react's c++ objects. If everything is just linked together in the ndk level then I could see this working out well.

from realm-js.

nhachicha avatar nhachicha commented on May 18, 2024

They did mention a native module written in C++ in the doc https://github.com/facebook/react-native/blob/b86a6e3b44a63e92cf3a7976d2fa26c4bf412df1/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeModule.java

{@link NativeModule}s whose implementation is written in C++

  • must not provide any Java code (so they can be reused on other platforms), and instead should
  • register themselves using {@link CxxModuleWrapper}.

I can't find this class they're mentioning in the Javadoc CxxModuleWrapper maybe we can use this wrapper to get hold of the context.

from realm-js.

alazier avatar alazier commented on May 18, 2024

@nhachicha that sounds promising. But I also can't find anything remotely similar to that in the code base. Perhaps the comment is stale? Would it be possible to have a Java module that calls into our own c++ code throught jni? If so how do we set this up? I'm not even sure where to begin.

from realm-js.

nhachicha avatar nhachicha commented on May 18, 2024

@alazier I'll give it a try once I finish this PR realm/realm-java#1809

from realm-js.

nhachicha avatar nhachicha commented on May 18, 2024

@alazier I created a sample project https://github.com/nhachicha/ReactNativeWithJni to showcase how we can create a native react module that uses JNI.

with this approach we can just expose the current Java binding as a JS module (since we're already traversing Java to call C/C++). What could be interesting in terms of performance is to manage to grab the JSContextRef, I know you're using some kind of reflection in Objective-C to access this property since it's private. Does it make sense to send a PR or to ask FB to expose it via a method so third party libraries can inject their API?

from realm-js.

alazier avatar alazier commented on May 18, 2024

Making progress here. All that is left now is chrome debugging and cleanup/proper support from react-native.

from realm-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.