Skip to content

Commit

Permalink
Promise support for C++ bridge
Browse files Browse the repository at this point in the history
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 d062cc2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ReactCommon/cxxreact/CxxNativeModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit d062cc2

Please sign in to comment.