Skip to content

Commit

Permalink
deprecate @Property methodQueue (facebook#41944)
Browse files Browse the repository at this point in the history
Summary:

Changelog: [iOS][Deprecated]

i think we can now communicate the deprecation of this selector.

after removing all of the synthesize methodQueue callsites in our codebase, our native modules are still stable, save for one native module, RCTNetworking. so i feel comfortable recommending users to create their own queues.

and after removing `methodQueue` overrides to support synchronous void methods, those modules are also still stable, so i'm also comfortable we can recommend handling the dispatch_async in the product layer.

Reviewed By: arushikesarwani94, cipolleschi

Differential Revision: D52150696
  • Loading branch information
philIip authored and facebook-github-bot committed Dec 14, 2023
1 parent b098297 commit 00f3cdd
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions packages/react-native/React/Base/RCTBridgeModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,27 +151,17 @@ RCT_EXTERN_C_END
@property (nonatomic, weak, readonly) RCTBridge *bridge RCT_DEPRECATED;

/**
* The queue that will be used to call all exported methods. If omitted, this
* will call on a default background queue, which is avoids blocking the main
* thread.
*
* If the methods in your module need to interact with UIKit methods, they will
* probably need to call those on the main thread, as most of UIKit is main-
* thread-only. You can tell React Native to call your module methods on the
* main thread by returning a reference to the main queue, like this:
*
* - (dispatch_queue_t)methodQueue
* {
* return dispatch_get_main_queue();
* }
*
* If you don't want to specify the queue yourself, but you need to use it
* inside your class (e.g. if you have internal methods that need to dispatch
* onto that queue), you can just add `@synthesize methodQueue = _methodQueue;`
* and the bridge will populate the methodQueue property for you automatically
* when it initializes the module.
* This property is deprecated. This selector used to support two functionalities.
*
* 1) Providing a queue to do additional async work.
* Instead of synthesizing this selector, retrieve a queue from GCD to do any asynchronous work.
* Example: _myQueue = dispatch_queue_create("myQueue", DISPATCH_QUEUE_SERIAL);
*
* 2) Overriding this in order to run all the module's methods on a specific queue, usually main.
* Instead of overriding this, directly dispatch the code onto main queue when necessary.
* Example: dispatch_async(dispatch_get_main_queue, ^{ ... });
*/
@property (nonatomic, strong, readonly) dispatch_queue_t methodQueue;
@property (nonatomic, strong, readonly) dispatch_queue_t methodQueue RCT_DEPRECATED;

/**
* Wrap the parameter line of your method implementation with this macro to
Expand Down

0 comments on commit 00f3cdd

Please sign in to comment.