Setting bridge up for sharing: allowing native modules to register after init

Reviewed By: javache

Differential Revision: D4945784

fbshipit-source-id: 80e7236e9ccd5d5c9a7fba7c96b98fc38b43a2fc
This commit is contained in:
Kathy Gray
2017-06-21 11:56:08 -07:00
committed by Facebook Github Bot
parent 1ae54b5108
commit 5c5410459e
13 changed files with 217 additions and 67 deletions

View File

@@ -157,6 +157,26 @@ public class CatalystInstanceImpl implements CatalystInstance {
}
}
/**
* This method and the native below permits a CatalystInstance to extend the known
* Native modules. This registry contains only the new modules to load. The
* registry {@code mNativeModuleRegistry} updates internally to contain all the new modules, and generates
* the new registry for extracting just the new collections.
*/
@Override
public void extendNativeModules(NativeModuleRegistry modules) {
//Extend the Java-visible registry of modules
mNativeModuleRegistry.registerModules(modules);
Collection<JavaModuleWrapper> javaModules = modules.getJavaModules(this);
Collection<ModuleHolder> cxxModules = modules.getCxxModules();
//Extend the Cxx-visible registry of modules wrapped in appropriate interfaces
jniExtendNativeModules(javaModules, cxxModules);
}
private native void jniExtendNativeModules(
Collection<JavaModuleWrapper> javaModules,
Collection<ModuleHolder> cxxModules);
private native void initializeBridge(
ReactCallback callback,
JavaScriptExecutor jsExecutor,