From ff8ec0bf3ac6ffcdc61319bef1b975a1595b7b31 Mon Sep 17 00:00:00 2001
From: Website Deployment Script
It is very important to highlight that the callback is not invoked immediately after the native function completes - remember that bridge communication is asynchronous, and this too is tied to the run loop.
Native modules can also fulfill a promise, which can simplify your code, especially when using ES2016's async/await syntax. When the last parameter of a bridged native method is a Promise, its corresponding JS method will return a JS Promise object.
Native modules can also fulfill a promise, which can simplify your JavaScript, especially when using ES2016's async/await syntax. When the last parameter of a bridged native method is a Promise, its corresponding JS method will return a JS Promise object.
Refactoring the above code to use a promise instead of callbacks looks like this:
import com.facebook.react.bridge.Promise;
diff --git a/docs/next/native-modules-android/index.html b/docs/next/native-modules-android/index.html
index 1e24b4eac2d..35ea06f5120 100644
--- a/docs/next/native-modules-android/index.html
+++ b/docs/next/native-modules-android/index.html
@@ -237,7 +237,7 @@ ToastExample.A native module is supposed to invoke its callback only once. It can, however, store the callback and invoke it later.
It is very important to highlight that the callback is not invoked immediately after the native function completes - remember that bridge communication is asynchronous, and this too is tied to the run loop.
Promises
-Native modules can also fulfill a promise, which can simplify your code, especially when using ES2016's async/await syntax. When the last parameter of a bridged native method is a Promise, its corresponding JS method will return a JS Promise object.
+Native modules can also fulfill a promise, which can simplify your JavaScript, especially when using ES2016's async/await syntax. When the last parameter of a bridged native method is a Promise, its corresponding JS method will return a JS Promise object.
Refactoring the above code to use a promise instead of callbacks looks like this:
import com.facebook.react.bridge.Promise;