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:
Lorenzo Blasa
2022-09-04 12:19:26 -07:00
committed by Facebook GitHub Bot
parent 322a1ba6b1
commit 6a9d54f93a
7 changed files with 388 additions and 7 deletions

View File

@@ -0,0 +1,52 @@
/*
* 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 "../../../../xplat/Flipper/FlipperPlugin.h"
namespace facebook {
namespace flipper {
enum class FlipperReactPluginEvent { CONNECTED, DISCONNECTED };
using FlipperConnectionEvent =
std::function<void(const std::string& pluginId, FlipperReactPluginEvent e)>;
class FlipperReactPlugin : public FlipperPlugin {
public:
FlipperReactPlugin(
std::string pluginId,
bool runInBackground,
FlipperConnectionEvent handler);
virtual ~FlipperReactPlugin();
virtual std::string identifier() const override;
virtual void didConnect(std::shared_ptr<FlipperConnection> conn) override;
virtual void didDisconnect() override;
virtual bool runInBackground() override;
void fireOnConnect();
void fireOnDisconnect();
bool isConnected();
FlipperConnection* getConnection();
private:
std::string pluginId_;
bool runInBackground_;
std::shared_ptr<FlipperConnection> connection_;
FlipperConnectionEvent eventHandler_;
};
} // namespace flipper
} // namespace facebook