Plugin and Module implementations
Summary: Last diff in the the RNW saga. This change creates the necessary bridgings between the module and the plugin. With this in place, JS plugins can be written and used. Also, we have a fully functional RNW sample app. Reviewed By: aigoncharov Differential Revision: D39087480 fbshipit-source-id: f4fde404716aa619a64553ffa556d060f49c0ac7
This commit is contained in:
committed by
Facebook GitHub Bot
parent
322a1ba6b1
commit
6a9d54f93a
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "FlipperReactPlugin.h"
|
||||
|
||||
namespace facebook {
|
||||
namespace flipper {
|
||||
|
||||
FlipperReactPlugin::FlipperReactPlugin(
|
||||
std::string pluginId,
|
||||
bool runInBackground,
|
||||
FlipperConnectionEvent handler)
|
||||
: pluginId_(std::move(pluginId)),
|
||||
runInBackground_(runInBackground),
|
||||
eventHandler_(std::move(handler)) {}
|
||||
|
||||
FlipperReactPlugin::~FlipperReactPlugin() {}
|
||||
|
||||
std::string FlipperReactPlugin::identifier() const {
|
||||
return pluginId_;
|
||||
}
|
||||
|
||||
void FlipperReactPlugin::didConnect(
|
||||
std::shared_ptr<FlipperConnection> connection) {
|
||||
connection_ = connection;
|
||||
fireOnConnect();
|
||||
}
|
||||
|
||||
void FlipperReactPlugin::didDisconnect() {
|
||||
connection_ = nullptr;
|
||||
fireOnDisconnect();
|
||||
}
|
||||
|
||||
bool FlipperReactPlugin::runInBackground() {
|
||||
return runInBackground_;
|
||||
}
|
||||
|
||||
void FlipperReactPlugin::fireOnConnect() {
|
||||
eventHandler_(pluginId_, FlipperReactPluginEvent::CONNECTED);
|
||||
}
|
||||
|
||||
void FlipperReactPlugin::fireOnDisconnect() {
|
||||
eventHandler_(pluginId_, FlipperReactPluginEvent::DISCONNECTED);
|
||||
}
|
||||
|
||||
bool FlipperReactPlugin::isConnected() {
|
||||
return connection_ != nullptr;
|
||||
}
|
||||
|
||||
FlipperConnection* FlipperReactPlugin::getConnection() {
|
||||
return connection_.get();
|
||||
}
|
||||
|
||||
} // namespace flipper
|
||||
} // namespace facebook
|
||||
Reference in New Issue
Block a user