forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce CallInvoker API for bridgeless modules (facebook#44378)
Summary: Pull Request resolved: facebook#44378 Changelog: [iOS][Added] introduce CallInvoker support in bridgeless native modules I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after facebook#43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API. Reviewed By: RSNara Differential Revision: D56807994 fbshipit-source-id: 5c3585356d016a50645eda3af2d3bbe00298b4e4
- Loading branch information
Showing
4 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#ifdef __cplusplus | ||
#import <ReactCommon/CallInvoker.h> | ||
#endif | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface RCTCallInvoker : NSObject | ||
|
||
#ifdef __cplusplus | ||
- (instancetype)initWithCallInvoker:(std::shared_ptr<facebook::react::CallInvoker>)callInvoker | ||
NS_DESIGNATED_INITIALIZER; | ||
|
||
- (std::shared_ptr<facebook::react::CallInvoker>)callInvoker; | ||
#endif | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import "RCTCallInvoker.h" | ||
|
||
@implementation RCTCallInvoker { | ||
std::shared_ptr<facebook::react::CallInvoker> _callInvoker; | ||
} | ||
|
||
- (instancetype)initWithCallInvoker:(std::shared_ptr<facebook::react::CallInvoker>)callInvoker | ||
{ | ||
if (self = [super init]) { | ||
_callInvoker = callInvoker; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
- (std::shared_ptr<facebook::react::CallInvoker>)callInvoker | ||
{ | ||
return _callInvoker; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
@class RCTCallInvoker; | ||
|
||
/** | ||
* Have your module conform to this protocol to access the CallInvoker. | ||
*/ | ||
@protocol RCTCallInvokerModule <NSObject> | ||
|
||
@property (nonatomic, nullable, readwrite) RCTCallInvoker *callInvoker; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters