Skip to content

Commit

Permalink
Refactor: Move ModuleProvider param to the end in TurboModuleBinding:…
Browse files Browse the repository at this point in the history
…:install()

Summary:
For the TurboModule interop layer, we'll pass in a second ModuleProvider. We'll default that second parameter to null, when the interop layer is disabled. This change will make that easier.

Changelog: [General][Changed] - Re-organize the parameters of TurboModuleBinding::install()

Reviewed By: javache, cortinico

Differential Revision: D43993199

fbshipit-source-id: 2d339cab1f9bfe481f4b72401caa203cd7536da1
  • Loading branch information
RSNara authored and facebook-github-bot committed Mar 15, 2023
1 parent aa28ea0 commit cbdbb47
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void TurboModuleManager::installJSIBindings() {
TurboModuleBindingMode bindingMode = static_cast<TurboModuleBindingMode>(
getFeatureFlagValue("turboModuleBindingMode"));
TurboModuleBinding::install(
runtime, std::move(turboModuleProvider), bindingMode);
runtime, bindingMode, std::move(turboModuleProvider));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ namespace react {
*/

TurboModuleBinding::TurboModuleBinding(
const TurboModuleProviderFunctionType &&moduleProvider,
TurboModuleBindingMode bindingMode)
: moduleProvider_(std::move(moduleProvider)), bindingMode_(bindingMode) {}
TurboModuleBindingMode bindingMode,
TurboModuleProviderFunctionType &&moduleProvider)
: bindingMode_(bindingMode), moduleProvider_(std::move(moduleProvider)) {}

void TurboModuleBinding::install(
jsi::Runtime &runtime,
const TurboModuleProviderFunctionType &&moduleProvider,
TurboModuleBindingMode bindingMode) {
TurboModuleBindingMode bindingMode,
TurboModuleProviderFunctionType &&moduleProvider) {
runtime.global().setProperty(
runtime,
"__turboModuleProxy",
Expand All @@ -39,7 +39,7 @@ void TurboModuleBinding::install(
jsi::PropNameID::forAscii(runtime, "__turboModuleProxy"),
1,
[binding =
TurboModuleBinding(std::move(moduleProvider), bindingMode)](
TurboModuleBinding(bindingMode, std::move(moduleProvider))](
jsi::Runtime &rt,
const jsi::Value &thisVal,
const jsi::Value *args,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ class TurboModuleBinding {
*/
static void install(
jsi::Runtime &runtime,
const TurboModuleProviderFunctionType &&moduleProvider,
TurboModuleBindingMode bindingMode);
TurboModuleBindingMode bindingMode,
TurboModuleProviderFunctionType &&moduleProvider);

private:
TurboModuleBinding(
const TurboModuleProviderFunctionType &&moduleProvider,
TurboModuleBindingMode bindingMode);
TurboModuleBindingMode bindingMode,
TurboModuleProviderFunctionType &&moduleProvider);
virtual ~TurboModuleBinding();

/**
Expand All @@ -48,8 +48,8 @@ class TurboModuleBinding {
jsi::Value getModule(jsi::Runtime &runtime, const std::string &moduleName)
const;

TurboModuleProviderFunctionType moduleProvider_;
TurboModuleBindingMode bindingMode_;
TurboModuleProviderFunctionType moduleProvider_;
};

} // namespace react
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ - (void)installJSBindingWithRuntimeExecutor:(facebook::react::RuntimeExecutor &)
};

runtimeExecutor([turboModuleProvider = std::move(turboModuleProvider)](jsi::Runtime &runtime) {
TurboModuleBinding::install(runtime, std::move(turboModuleProvider), sTurboModuleBindingMode);
TurboModuleBinding::install(runtime, sTurboModuleBindingMode, std::move(turboModuleProvider));
});
}

Expand Down

0 comments on commit cbdbb47

Please sign in to comment.