mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
4c998fd05d
Summary: ## Motivation The concept behind JSCallInvoker doesn't necessarily have to apply only to the JS thread. On Android, we need to re-use this abstraction to allow execution of async method calls on the NativeModules thread. Reviewed By: PeteTheHeat Differential Revision: D17377313 fbshipit-source-id: 3d9075cbfce0b908d800a366947cfd16a3013d1c
50 lines
1.3 KiB
C++
50 lines
1.3 KiB
C++
/**
|
|
* Copyright (c) Facebook, Inc. and its 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 <memory>
|
|
#include <vector>
|
|
|
|
#include <cxxreact/CxxModule.h>
|
|
|
|
#include "TurboModule.h"
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
/**
|
|
* A helper class to convert the legacy CxxModule instance to a TurboModule
|
|
* instance. This should be used only for migration purpose (to TurboModule),
|
|
* since it's not very performant due to a lot of back-and-forth value
|
|
* conversions between folly::dynamic and jsi::Value.
|
|
*/
|
|
class JSI_EXPORT TurboCxxModule : public TurboModule {
|
|
public:
|
|
TurboCxxModule(
|
|
std::unique_ptr<facebook::xplat::module::CxxModule> cxxModule,
|
|
std::shared_ptr<CallInvoker> jsInvoker);
|
|
|
|
virtual facebook::jsi::Value get(
|
|
facebook::jsi::Runtime &runtime,
|
|
const facebook::jsi::PropNameID &propName) override;
|
|
|
|
jsi::Value invokeMethod(
|
|
jsi::Runtime &runtime,
|
|
TurboModuleMethodValueKind valueKind,
|
|
const std::string &methodName,
|
|
const jsi::Value *args,
|
|
size_t count);
|
|
|
|
private:
|
|
std::vector<facebook::xplat::module::CxxModule::Method> cxxMethods_;
|
|
std::unique_ptr<facebook::xplat::module::CxxModule> cxxModule_;
|
|
};
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|