mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Remove CxxSharedModuleWrapper from open-source (#52672)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52672 This was used internally to work around some limitations of the bridge lifecycle. Given that we now have C++ TurboModules which are much more versatile, let's remove unnecessary concepts externally, as we move towards deprecating legacy C++ modules entirely. Changelog: [General][Breaking] Removed CxxSharedModuleWrapper Reviewed By: rshest Differential Revision: D78484221 fbshipit-source-id: 95ed46b597dac55d823b70abe196264ce5b326ab
This commit is contained in:
committed by
Facebook GitHub Bot
parent
72158fc13a
commit
fafbee2402
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* 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 <cxxreact/SharedProxyCxxModule.h>
|
||||
|
||||
#include "CxxModuleWrapperBase.h"
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
class CxxSharedModuleWrapper : public CxxModuleWrapperBase {
|
||||
public:
|
||||
std::string getName() override {
|
||||
return shared_->getName();
|
||||
}
|
||||
|
||||
std::unique_ptr<xplat::module::CxxModule> getModule() override {
|
||||
// Instead of just moving out the stored CxxModule, this creates a
|
||||
// proxy which passes calls to the shared stored CxxModule.
|
||||
|
||||
return std::make_unique<xplat::module::SharedProxyCxxModule>(shared_);
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit CxxSharedModuleWrapper(
|
||||
std::unique_ptr<xplat::module::CxxModule> module)
|
||||
: shared_(std::move(module)) {}
|
||||
|
||||
std::shared_ptr<xplat::module::CxxModule> shared_;
|
||||
};
|
||||
|
||||
} // namespace facebook::react
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* 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 <memory>
|
||||
|
||||
#include <cxxreact/CxxModule.h>
|
||||
|
||||
namespace facebook::xplat::module {
|
||||
|
||||
// Allows a Cxx-module to be shared or reused across multiple React instances
|
||||
// Caveat: the setInstance call is not forwarded, so usages of getInstance
|
||||
// inside your module (e.g. dispatching events) will always be nullptr.
|
||||
class SharedProxyCxxModule : public CxxModule {
|
||||
public:
|
||||
explicit SharedProxyCxxModule(std::shared_ptr<CxxModule> shared)
|
||||
: shared_(shared) {}
|
||||
|
||||
std::string getName() override {
|
||||
return shared_->getName();
|
||||
}
|
||||
|
||||
auto getConstants() -> std::map<std::string, folly::dynamic> override {
|
||||
return shared_->getConstants();
|
||||
}
|
||||
|
||||
auto getMethods() -> std::vector<Method> override {
|
||||
return shared_->getMethods();
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<CxxModule> shared_;
|
||||
};
|
||||
|
||||
} // namespace facebook::xplat::module
|
||||
Reference in New Issue
Block a user