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
This commit is contained in:
Alex Kotliarskyi 2017-06-08 11:45:27 -07:00 коммит произвёл Facebook Github Bot
Родитель cbb8d6f628
Коммит d062cc252e
1 изменённых файлов: 2 добавлений и 1 удалений

Просмотреть файл

@ -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;
}