react-native/ReactCommon/cxxreact/CxxNativeModule.h
Marc Horowitz da2684f0e7 Refactor CxxNativeModule out of android-specific code into common code
Differential Revision: D3574789

fbshipit-source-id: 0cb5965d20dcf7accb6a94514486b8fda1126b7b
2016-08-03 16:01:24 -07:00

38 lines
1.0 KiB
C++

// Copyright 2004-present Facebook. All Rights Reserved.
#pragma once
#include "NativeModule.h"
#include <cxxreact/CxxModule.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_;
};
}
}