diff --git a/releases/next/docs/native-modules-ios.html b/releases/next/docs/native-modules-ios.html index 9586c910223..bc2be48686e 100644 --- a/releases/next/docs/native-modules-ios.html +++ b/releases/next/docs/native-modules-ios.html @@ -111,29 +111,65 @@ RCTRootView *rootView }; RCT_EXPORT_METHOD(updateStatusBarAnimation:(UIStatusBarAnimation)animation - completion:(RCTResponseSenderBlock)callback)
Your enum will then be automatically unwrapped using the selector provided (integerValue in the above example) before being passed to your exported method.
The native module can signal events to JavaScript without being invoked directly. The easiest way to do this is to use eventDispatcher:
Your enum will then be automatically unwrapped using the selector provided (integerValue in the above example) before being passed to your exported method.
The native module can signal events to JavaScript without being invoked directly. The preferred way to do this is to subclass RCTEventEmitter, implement suppportEvents and call self sendEventWithName:
JavaScript code can subscribe to these events:
JavaScript code can subscribe to these events by creating a new NativeEventEmitter instance around your module.
For more examples of sending events to JavaScript, see RCTLocationObserver.
Swift doesn't have support for macros so exposing it to React Native requires a bit more setup but works relatively the same.
Let's say we have the same CalendarManager but as a Swift class:
For more examples of sending events to JavaScript, see RCTLocationObserver.
You will receive a warning if you expend resources unnecessarily by emitting an event while there are no listeners. To avoid this, and to optimize your module's workload (e.g. by unsubscribing from upstream notifications or pausing background tasks), you can override startObserving and stopObserving in your RCTEventEmitter subclass.
Swift doesn't have support for macros so exposing it to React Native requires a bit more setup but works relatively the same.
Let's say we have the same CalendarManager but as a Swift class: