mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-06 09:13:27 +08:00
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:
committed by
Facebook Github Bot
parent
1ae54b5108
commit
5c5410459e
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <unordered_set>
|
||||
|
||||
#include <cxxreact/NativeModule.h>
|
||||
#include <folly/Optional.h>
|
||||
@@ -42,8 +43,15 @@ class ModuleRegistry {
|
||||
// This is always populated
|
||||
std::vector<std::unique_ptr<NativeModule>> modules_;
|
||||
|
||||
// This is used to extend the population of modulesByName_ if registerModules is called after moduleNames
|
||||
void updateModuleNamesFromIndex(size_t size);
|
||||
|
||||
// This is only populated if moduleNames() is called. Values are indices into modules_.
|
||||
std::unordered_map<std::string, size_t> modulesByName_;
|
||||
|
||||
// This is populated with modules that are requested via getConfig but are unknown.
|
||||
// An error will be thrown if they are subsquently added to the registry.
|
||||
std::unordered_set<std::string> unknownModules_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user