Files
react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.h
T
Ramanpreet Nara cbdbb47467 Refactor: Move ModuleProvider param to the end in TurboModuleBinding::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
2023-03-14 21:16:22 -07:00

57 lines
1.3 KiB
C++

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <string>
#include <ReactCommon/TurboModule.h>
#include <jsi/jsi.h>
namespace facebook {
namespace react {
enum class TurboModuleBindingMode : uint8_t {
HostObject = 0,
Prototype = 1,
Eager = 2,
};
/**
* Represents the JavaScript binding for the TurboModule system.
*/
class TurboModuleBinding {
public:
/*
* Installs TurboModuleBinding into JavaScript runtime.
* Thread synchronization must be enforced externally.
*/
static void install(
jsi::Runtime &runtime,
TurboModuleBindingMode bindingMode,
TurboModuleProviderFunctionType &&moduleProvider);
private:
TurboModuleBinding(
TurboModuleBindingMode bindingMode,
TurboModuleProviderFunctionType &&moduleProvider);
virtual ~TurboModuleBinding();
/**
* A lookup function exposed to JS to get an instance of a TurboModule
* for the given name.
*/
jsi::Value getModule(jsi::Runtime &runtime, const std::string &moduleName)
const;
TurboModuleBindingMode bindingMode_;
TurboModuleProviderFunctionType moduleProvider_;
};
} // namespace react
} // namespace facebook