mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Revert D16553363: [RN][TurboModule] Make TurboModules long-lived on Android
Differential Revision: D16553363 Original commit changeset: c95e150d6967 fbshipit-source-id: d035724ce131b560abc70e94410d727951a83241
This commit is contained in:
committed by
Facebook Github Bot
parent
5263660c07
commit
283a9dcc11
+2
-12
@@ -56,30 +56,20 @@ void TurboModuleManager::installJSIBindings() {
|
||||
}
|
||||
TurboModuleBinding::install(*runtime_, std::make_shared<TurboModuleBinding>(
|
||||
[this](const std::string &name) -> std::shared_ptr<TurboModule> {
|
||||
auto turboModuleLookup = turboModuleCache_.find(name);
|
||||
if (turboModuleLookup != turboModuleCache_.end()) {
|
||||
return turboModuleLookup->second;
|
||||
}
|
||||
|
||||
auto cxxModule = turboModuleManagerDelegate_->cthis()->getTurboModule(name, jsCallInvoker_);
|
||||
if (cxxModule) {
|
||||
turboModuleCache_.insert({name, cxxModule});
|
||||
return cxxModule;
|
||||
}
|
||||
|
||||
auto legacyCxxModule = getLegacyCxxJavaModule(name);
|
||||
if (legacyCxxModule) {
|
||||
auto turboModule = std::make_shared<react::TurboCxxModule>(legacyCxxModule->cthis()->getModule(), jsCallInvoker_);
|
||||
turboModuleCache_.insert({name, turboModule});
|
||||
return turboModule;
|
||||
return std::make_shared<react::TurboCxxModule>(legacyCxxModule->cthis()->getModule(), jsCallInvoker_);
|
||||
}
|
||||
|
||||
auto moduleInstance = getJavaModule(name);
|
||||
|
||||
if (moduleInstance) {
|
||||
auto turboModule = turboModuleManagerDelegate_->cthis()->getTurboModule(name, moduleInstance, jsCallInvoker_);
|
||||
turboModuleCache_.insert({name, turboModule});
|
||||
return turboModule;
|
||||
return turboModuleManagerDelegate_->cthis()->getTurboModule(name, moduleInstance, jsCallInvoker_);
|
||||
}
|
||||
|
||||
return std::shared_ptr<TurboModule>(nullptr);
|
||||
|
||||
-9
@@ -8,7 +8,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <fb/fbjni.h>
|
||||
#include <jsi/jsi.h>
|
||||
#include <ReactCommon/TurboModule.h>
|
||||
@@ -38,14 +37,6 @@ private:
|
||||
std::shared_ptr<JSCallInvoker> jsCallInvoker_;
|
||||
jni::global_ref<TurboModuleManagerDelegate::javaobject> turboModuleManagerDelegate_;
|
||||
|
||||
/**
|
||||
* TODO(T48018690):
|
||||
* All modules are currently long-lived.
|
||||
* We need to come up with a mechanism to allow modules to specify whether
|
||||
* they want to be long-lived or short-lived.
|
||||
*/
|
||||
std::unordered_map<std::string, std::shared_ptr<react::TurboModule>> turboModuleCache_;
|
||||
|
||||
jni::global_ref<JTurboModule> getJavaModule(std::string name);
|
||||
jni::global_ref<CxxModuleWrapper::javaobject> getLegacyCxxJavaModule(std::string name);
|
||||
void installJSIBindings();
|
||||
|
||||
Reference in New Issue
Block a user