Remove isValid from RCTInvalidating
Summary: We only actually use it on RCTBridge and RCTJavaScriptExecutor, so add it to these interfaces explicitly
This commit is contained in:
Родитель
f5d68f6ecb
Коммит
fa07736ee1
|
@ -42,15 +42,16 @@ _Pragma("clang diagnostic pop")
|
|||
@end
|
||||
|
||||
@interface AllocationTestModule : NSObject<RCTBridgeModule, RCTInvalidating>
|
||||
|
||||
@property (nonatomic, assign, getter=isValid) BOOL valid;
|
||||
|
||||
@end
|
||||
|
||||
@implementation AllocationTestModule
|
||||
|
||||
RCT_EXPORT_MODULE();
|
||||
|
||||
@synthesize valid = _valid;
|
||||
|
||||
- (id)init
|
||||
- (instancetype)init
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_valid = YES;
|
||||
|
|
|
@ -62,6 +62,7 @@ id<RCTJavaScriptExecutor> RCTGetLatestExecutor(void)
|
|||
@implementation RCTBatchedBridge
|
||||
{
|
||||
BOOL _loading;
|
||||
BOOL _valid;
|
||||
__weak id<RCTJavaScriptExecutor> _javaScriptExecutor;
|
||||
NSMutableArray *_moduleDataByID;
|
||||
RCTModuleMap *_modulesByName;
|
||||
|
@ -72,8 +73,6 @@ id<RCTJavaScriptExecutor> RCTGetLatestExecutor(void)
|
|||
RCTSparseArray *_scheduledCallbacks;
|
||||
}
|
||||
|
||||
@synthesize valid = _valid;
|
||||
|
||||
- (instancetype)initWithParentBridge:(RCTBridge *)bridge
|
||||
{
|
||||
RCTAssertMainThread();
|
||||
|
|
|
@ -145,6 +145,11 @@ RCT_EXTERN NSString *RCTBridgeModuleNameForClass(Class bridgeModuleClass);
|
|||
*/
|
||||
@property (nonatomic, readonly, getter=isLoading) BOOL loading;
|
||||
|
||||
/**
|
||||
* Use this to check if the bridge has been invalidated.
|
||||
*/
|
||||
@property (nonatomic, readonly, getter=isValid) BOOL valid;
|
||||
|
||||
/**
|
||||
* The block passed in the constructor with pre-initialized modules
|
||||
*/
|
||||
|
|
|
@ -244,11 +244,6 @@ RCT_NOT_IMPLEMENTED(-init)
|
|||
return _batchedBridge.loading;
|
||||
}
|
||||
|
||||
- (BOOL)isValid
|
||||
{
|
||||
return _batchedBridge.isValid;
|
||||
}
|
||||
|
||||
- (void)invalidate
|
||||
{
|
||||
RCTAssertMainThread();
|
||||
|
@ -260,7 +255,7 @@ RCT_NOT_IMPLEMENTED(-init)
|
|||
+ (void)logMessage:(NSString *)message level:(NSString *)level
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (!RCTGetLatestExecutor().isValid) {
|
||||
if (![RCTGetLatestExecutor() isValid]) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,13 +9,8 @@
|
|||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
// TODO (#5906496): This protocol is only used to add method definitions to
|
||||
// classes. We should decide if it's actually necessary.
|
||||
|
||||
@protocol RCTInvalidating <NSObject>
|
||||
|
||||
@property (nonatomic, assign, readonly, getter = isValid) BOOL valid;
|
||||
|
||||
- (void)invalidate;
|
||||
|
||||
@end
|
||||
|
|
|
@ -29,6 +29,11 @@ typedef void (^RCTJavaScriptCallback)(id json, NSError *error);
|
|||
*/
|
||||
- (void)setUp;
|
||||
|
||||
/**
|
||||
* Whether the executor has been invalidated
|
||||
*/
|
||||
@property (nonatomic, readonly, getter=isValid) BOOL valid;
|
||||
|
||||
/**
|
||||
* Executes given method with arguments on JS thread and calls the given callback
|
||||
* with JSValue and JSContext as a result of the JS module call.
|
||||
|
|
|
@ -292,14 +292,9 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
|
|||
[_bridge.uiManager registerRootView:self];
|
||||
}
|
||||
|
||||
- (BOOL)isValid
|
||||
{
|
||||
return self.userInteractionEnabled;
|
||||
}
|
||||
|
||||
- (void)invalidate
|
||||
{
|
||||
if (self.isValid) {
|
||||
if (self.userInteractionEnabled) {
|
||||
self.userInteractionEnabled = NO;
|
||||
[(RCTRootView *)self.superview contentViewInvalidated];
|
||||
[_bridge enqueueJSCall:@"ReactNative.unmountComponentAtNodeAndRemoveContainer"
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
@property (nonatomic, assign) BOOL clearOnInvalidate;
|
||||
|
||||
@property (nonatomic, readonly, getter=isValid) BOOL valid;
|
||||
|
||||
- (void)multiGet:(NSArray *)keys callback:(RCTResponseSenderBlock)callback;
|
||||
- (void)multiSet:(NSArray *)kvPairs callback:(RCTResponseSenderBlock)callback;
|
||||
- (void)multiRemove:(NSArray *)keys callback:(RCTResponseSenderBlock)callback;
|
||||
|
|
|
@ -164,6 +164,7 @@ RCT_EXPORT_MODULE()
|
|||
_manifest = [[NSMutableDictionary alloc] init];
|
||||
_haveSetup = NO;
|
||||
}
|
||||
|
||||
- (BOOL)isValid
|
||||
{
|
||||
return _haveSetup;
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTBridgeModule.h"
|
||||
#import "RCTInvalidating.h"
|
||||
|
||||
/**
|
||||
* Developer menu, useful for exposing extra functionality when debugging.
|
||||
|
|
|
@ -223,11 +223,6 @@ RCT_EXPORT_MODULE()
|
|||
});
|
||||
}
|
||||
|
||||
- (BOOL)isValid
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[_updateTask cancel];
|
||||
|
|
|
@ -112,11 +112,6 @@ RCT_EXPORT_MODULE()
|
|||
return RCTJSThread;
|
||||
}
|
||||
|
||||
- (BOOL)isValid
|
||||
{
|
||||
return _bridge != nil;
|
||||
}
|
||||
|
||||
- (void)invalidate
|
||||
{
|
||||
[self stopTimers];
|
||||
|
@ -130,7 +125,7 @@ RCT_EXPORT_MODULE()
|
|||
|
||||
- (void)startTimers
|
||||
{
|
||||
if (![self isValid] || _timers.count == 0) {
|
||||
if (!_bridge || _timers.count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -253,11 +253,6 @@ extern NSString *RCTBridgeModuleNameForClass(Class cls);
|
|||
});
|
||||
}
|
||||
|
||||
- (BOOL)isValid
|
||||
{
|
||||
return _viewRegistry != nil;
|
||||
}
|
||||
|
||||
- (void)invalidate
|
||||
{
|
||||
/**
|
||||
|
@ -325,7 +320,7 @@ extern NSString *RCTBridgeModuleNameForClass(Class cls);
|
|||
__weak RCTUIManager *weakSelf = self;
|
||||
dispatch_async(_shadowQueue, ^{
|
||||
RCTUIManager *strongSelf = weakSelf;
|
||||
if (!strongSelf.isValid) {
|
||||
if (!_viewRegistry) {
|
||||
return;
|
||||
}
|
||||
RCTShadowView *shadowView = [[RCTShadowView alloc] init];
|
||||
|
@ -369,7 +364,7 @@ extern NSString *RCTBridgeModuleNameForClass(Class cls);
|
|||
__weak RCTUIManager *weakSelf = self;
|
||||
dispatch_async(_shadowQueue, ^{
|
||||
RCTUIManager *strongSelf = weakSelf;
|
||||
if (!strongSelf.isValid) {
|
||||
if (!_viewRegistry) {
|
||||
return;
|
||||
}
|
||||
RCTShadowView *rootShadowView = strongSelf->_shadowViewRegistry[reactTag];
|
||||
|
@ -410,14 +405,14 @@ extern NSString *RCTBridgeModuleNameForClass(Class cls);
|
|||
return;
|
||||
}
|
||||
|
||||
if (!self.isValid) {
|
||||
if (!_viewRegistry) {
|
||||
return;
|
||||
}
|
||||
|
||||
__weak RCTUIManager *weakViewManager = self;
|
||||
dispatch_block_t outerBlock = ^{
|
||||
RCTUIManager *strongViewManager = weakViewManager;
|
||||
if (strongViewManager && strongViewManager.isValid) {
|
||||
if (strongViewManager && strongViewManager->_viewRegistry) {
|
||||
block(strongViewManager, strongViewManager->_viewRegistry);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "RCTFrameUpdate.h"
|
||||
#import "RCTInvalidating.h"
|
||||
|
||||
@class RCTBridge;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче