diff --git a/docs/native-modules-ios.html b/docs/native-modules-ios.html index b2031cdf88a..5c770752b80 100644 --- a/docs/native-modules-ios.html +++ b/docs/native-modules-ios.html @@ -42,8 +42,8 @@ CalendarManager.this.setState({events: events}); } })
A native module is supposed to invoke its callback only once. It can, however, store the callback and invoke it later. This pattern is often used to wrap iOS APIs that require delegates. See RCTAlertManager for an example.
If you want to pass error-like objects to JavaScript, use RCTMakeError from RCTUtils.h. Right now this just passes an Error-shaped dictionary to JavaScript, but we would like to automatically generate real JavaScript Error objects in the future.
Native modules can also fulfill a promise, which can simplify your code, especially when using ES2016's async/await syntax. When the last parameters of a bridged native method are an RCTPromiseResolveBlock and RCTPromiseRejectBlock, its corresponding JS method will return a JS Promise object.
Refactoring the above code to use a promise instead of callbacks looks like this: