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

@@ -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_;
};
}