mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-22 11:16:06 +08:00
Lazily instantiate native modules
Summary: Instead of sending a list of modules over to JS on startup (and actually blocking script execution) instead provide a proxy object that constructs each of these lazily. Reviewed By: lexs Differential Revision: D3936979 fbshipit-source-id: 71bde822f01eb17a29f56c5e60e95e98e207d74d
This commit is contained in:
committed by
Facebook Github Bot
parent
606fc11487
commit
9ed9bca0bf
@@ -6,6 +6,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include <folly/dynamic.h>
|
||||
#include <folly/Optional.h>
|
||||
|
||||
#include "ExecutorToken.h"
|
||||
#include "NativeModule.h"
|
||||
@@ -15,6 +16,11 @@ namespace react {
|
||||
|
||||
class NativeModule;
|
||||
|
||||
struct ModuleConfig {
|
||||
size_t index;
|
||||
folly::dynamic config;
|
||||
};
|
||||
|
||||
class ModuleRegistry {
|
||||
public:
|
||||
// not implemented:
|
||||
@@ -26,7 +32,9 @@ class ModuleRegistry {
|
||||
|
||||
ModuleRegistry(std::vector<std::unique_ptr<NativeModule>> modules);
|
||||
std::vector<std::string> moduleNames();
|
||||
folly::dynamic getConfig(const std::string& name);
|
||||
|
||||
folly::Optional<ModuleConfig> getConfig(const std::string& name);
|
||||
|
||||
void callNativeMethod(ExecutorToken token, unsigned int moduleId, unsigned int methodId,
|
||||
folly::dynamic&& params, int callId);
|
||||
MethodCallResult callSerializableNativeHook(ExecutorToken token, unsigned int moduleId, unsigned int methodId, folly::dynamic&& args);
|
||||
|
||||
Reference in New Issue
Block a user