tighter ContextContainer semantics

Summary:
shergin mentioned that he'd like to move away from RTTI a bit and use explicit key strings for context container instances rather than relying on the `typeid`, so this does this.

We also fatal with a useful error message if we get a collision, rather than failing silently.

Reviewed By: shergin

Differential Revision: D13384308

fbshipit-source-id: 0b06d7555b082be89e8f130c23e94be99749a7a3
This commit is contained in:
Spencer Ahrens
2018-12-21 17:57:32 -08:00
committed by Facebook Github Bot
parent a3b348eacb
commit 34ea65e3d9
4 changed files with 27 additions and 22 deletions

View File

@@ -173,7 +173,7 @@ using namespace facebook::react;
_scheduler = [[RCTScheduler alloc] initWithContextContainer:self.contextContainer];
_scheduler.delegate = self;
return _scheduler;
}
@@ -182,14 +182,14 @@ using namespace facebook::react;
- (SharedContextContainer)contextContainer
{
std::lock_guard<std::mutex> lock(_contextContainerMutex);
if (_contextContainer) {
return _contextContainer;
}
_contextContainer = std::make_shared<ContextContainer>();
_contextContainer->registerInstance(_reactNativeConfig);
_contextContainer->registerInstance(_reactNativeConfig, "ReactNativeConfig");
auto messageQueueThread = _batchedBridge.jsMessageThread;
auto runtime = (facebook::jsi::Runtime *)((RCTCxxBridge *)_batchedBridge).runtime;
@@ -214,7 +214,7 @@ using namespace facebook::react;
_contextContainer->registerInstance(runtimeExecutor, "runtime-executor");
_contextContainer->registerInstance(std::make_shared<ImageManager>((__bridge void *)[_bridge imageLoader]));
_contextContainer->registerInstance(std::make_shared<ImageManager>((__bridge void *)[_bridge imageLoader]), "ImageManager");
return _contextContainer;
}