mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/36630 ## Changes This diff hooks up global.nativeModuleProxy to the TurboModule interop layer. Now, when you call NativeModules.Foo, the TurboModule system will create the Foo interop module, and return it to JavaScript. |**Language**|**Abstraction**|**Description**| |Java/C++|MethodDescriptor| The information needed by JavaTurboModule::invokeJavaMethod() to execute a module method: [example](https://www.internalfb.com/code/fbsource/[78577e97310db97c489e976168ca6ddf4cb894c3]/xplat/js/react-native-github/ReactCommon/react/nativemodule/samples/platform/android/ReactCommon/SampleTurboModuleSpec.cpp?lines=34-36).| |Java|TurboModuleInteropUtils| Takes the interop module object, and parses out MethodDescriptors from the methods annotated with ReactMethod| |C++|JavaInteropTurboModule| Facilitates JavaScript -> Java method dispatch for interop modules. Extends [JavaTurboModule](https://www.internalfb.com/code/fbsource/[6f0698784af39dd0e881d9a69087ae6ac5e9cdc4]/xplat/js/react-native-github/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.h?lines=28). Needs to be created with a list of MethodDescriptors.| Shape of MethodDescriptor: ``` class MethodDescriptor { String methodName; String jniSignature; String jsiReturnKind; int jsArgCount; } ``` ## Example global.nativeModuleProxy.Foo: 1. **Java:** Use TurboModuleManager to create the Java interop module for Foo 2. **Java:** Use TurboModuleInteropUtils to generate Foo's MethodDescriptors 3. **C++:** Use Foo's MethodDescriptors to create, cache, and return a JavaInteropTurboModule object to JavaScript. Changelog: [Internal] Reviewed By: cortinico Differential Revision: D43918998 fbshipit-source-id: 562d3d7dc7f2ddb085dea6e94d72e1601012b741