Permalink
Browse files

Promise support for C++ bridge

Summary: Looks like `CxxModule::Method` already supports 0..2 callbacks. Based on Obj-C implementation (RCTModuleMethod.m:492) and JS bridge code (NativeModules.js:76), 2 callbacks native method is transformed to JS promise by JS part of the bridge.

Reviewed By: javache

Differential Revision: D5207852

fbshipit-source-id: 5aad86d45b97397f2bc3a4dbc648a60d96a4689e
  • Loading branch information...
frantic authored and facebook-github-bot committed Jun 8, 2017
1 parent cbb8d6f commit d062cc252efbd22cb469c22c8b373d17acee86a4
Showing with 2 additions and 1 deletion.
  1. +2 −1 ReactCommon/cxxreact/CxxNativeModule.cpp
@@ -57,7 +57,8 @@ std::vector<MethodDescriptor> CxxNativeModule::getMethods() {
std::vector<MethodDescriptor> descs;
for (auto& method : methods_) {
assert(method.func || method.syncFunc);
descs.emplace_back(method.name, method.func ? "async" : "sync");
auto methodType = method.func ? (method.callbacks == 2 ? "promise" : "async") : "sync";
descs.emplace_back(method.name, methodType);
}
return descs;
}

0 comments on commit d062cc2

Please sign in to comment.