mirror of
https://github.com/status-im/react-native.git
synced 2025-01-17 13:01:13 +00:00
c38d56d9db
Summary: In order for `CxxModule` modules to be able to do things like emit events, we need to expose the bridge instance. To allow classes derived from `CxxModule` in other projects to include `<cxxreact/Instance.h> I also needed to convert all the header includes to non-relative ones. Reviewed By: javache Differential Revision: D4564145 fbshipit-source-id: a5bc28dd9b40e2b141af9e867105c56083fbdcdc
37 lines
1.0 KiB
C++
37 lines
1.0 KiB
C++
// Copyright 2004-present Facebook. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include <cxxreact/CxxModule.h>
|
|
#include <cxxreact/NativeModule.h>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
class Instance;
|
|
|
|
std::function<void(folly::dynamic)> makeCallback(
|
|
std::weak_ptr<Instance> instance, ExecutorToken token, const folly::dynamic& callbackId);
|
|
|
|
class CxxNativeModule : public NativeModule {
|
|
public:
|
|
CxxNativeModule(std::weak_ptr<Instance> instance,
|
|
std::unique_ptr<xplat::module::CxxModule> module);
|
|
|
|
std::string getName() override;
|
|
std::vector<MethodDescriptor> getMethods() override;
|
|
folly::dynamic getConstants() override;
|
|
bool supportsWebWorkers() override;
|
|
void invoke(ExecutorToken token, unsigned int reactMethodId, folly::dynamic&& params) override;
|
|
MethodCallResult callSerializableNativeHook(
|
|
ExecutorToken token, unsigned int hookId, folly::dynamic&& args) override;
|
|
|
|
private:
|
|
std::weak_ptr<Instance> instance_;
|
|
std::unique_ptr<xplat::module::CxxModule> module_;
|
|
std::vector<xplat::module::CxxModule::Method> methods_;
|
|
};
|
|
|
|
}
|
|
}
|