Skip to content

Commit

Permalink
[skip ci] Bridgeless: Unify legacyModuleProvider setup (facebook#42790)
Browse files Browse the repository at this point in the history
Summary:

A tiny bit of refactoring to unify the setup

Changelog: [Internal]

Differential Revision: D53313332
  • Loading branch information
christophpurrer authored and facebook-github-bot committed Feb 1, 2024
1 parent a0b1073 commit 411557a
Showing 1 changed file with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,24 +126,19 @@ void TurboModuleBinding::install(
}));

if (runtime.global().hasProperty(runtime, "RN$Bridgeless")) {
if (legacyModuleProvider != nullptr) {
defineReadOnlyGlobal(runtime, "RN$TurboInterop", jsi::Value(true));
defineReadOnlyGlobal(
runtime,
"nativeModuleProxy",
jsi::Object::createFromHostObject(
runtime,
std::make_shared<BridgelessNativeModuleProxy>(
std::make_unique<TurboModuleBinding>(
std::move(legacyModuleProvider),
longLivedObjectCollection))));
} else {
defineReadOnlyGlobal(
runtime,
"nativeModuleProxy",
jsi::Object::createFromHostObject(
runtime, std::make_shared<BridgelessNativeModuleProxy>(nullptr)));
}
bool rnTurboInterop = legacyModuleProvider != nullptr;
auto turboModuleBinding = legacyModuleProvider
? std::make_unique<TurboModuleBinding>(
std::move(legacyModuleProvider), longLivedObjectCollection)
: nullptr;
auto nativeModuleProxy = std::make_shared<BridgelessNativeModuleProxy>(
std::move(turboModuleBinding));
defineReadOnlyGlobal(
runtime, "RN$TurboInterop", jsi::Value(rnTurboInterop));
defineReadOnlyGlobal(
runtime,
"nativeModuleProxy",
jsi::Object::createFromHostObject(runtime, nativeModuleProxy));
}
}

Expand Down

0 comments on commit 411557a

Please sign in to comment.