mirror of
https://github.com/status-im/react-native.git
synced 2025-02-23 06:38:13 +00:00
Summary: This may be controversial. Right now, RelayPrefetcher is initialized [here](https://fburl.com/p01iunr1), after bridge is initialized. I want to create a FBRelayPrefetcherModule instance eagerly (diff 3 in stack), and then pass that into the bridge module registry. This way, native side gets to use RelayPrefetcher before bridge is init, and JS still accesses the same instance of FBRelayPrefetcherModule. The only other option is drastically change bridge init, to allow passing in some eagerly initialized instances. Reviewed By: shergin Differential Revision: D13164277 fbshipit-source-id: b45111cd68d78820e61e4fca7e54a7e8df32a3f0
92 lines
2.9 KiB
Objective-C
92 lines
2.9 KiB
Objective-C
/**
|
|
* Copyright (c) Facebook, Inc. and its 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>
|
|
|
|
#import <React/RCTInvalidating.h>
|
|
|
|
@protocol RCTBridgeMethod;
|
|
@protocol RCTBridgeModule;
|
|
@class RCTBridge;
|
|
|
|
typedef id<RCTBridgeModule>(^RCTBridgeModuleProvider)(void);
|
|
|
|
@interface RCTModuleData : NSObject <RCTInvalidating>
|
|
|
|
- (instancetype)initWithModuleClass:(Class)moduleClass
|
|
bridge:(RCTBridge *)bridge;
|
|
|
|
- (instancetype)initWithModuleClass:(Class)moduleClass
|
|
moduleProvider:(RCTBridgeModuleProvider)moduleProvider
|
|
bridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER;
|
|
|
|
- (instancetype)initWithModuleInstance:(id<RCTBridgeModule>)instance
|
|
bridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER;
|
|
|
|
/**
|
|
* Calls `constantsToExport` on the module and stores the result. Note that
|
|
* this will init the module if it has not already been created. This method
|
|
* can be called on any thread, but may block the main thread briefly if the
|
|
* module implements `constantsToExport`.
|
|
*/
|
|
- (void)gatherConstants;
|
|
|
|
@property (nonatomic, strong, readonly) Class moduleClass;
|
|
@property (nonatomic, copy, readonly) NSString *name;
|
|
|
|
/**
|
|
* Returns the module methods. Note that this will gather the methods the first
|
|
* time it is called and then memoize the results.
|
|
*/
|
|
@property (nonatomic, copy, readonly) NSArray<id<RCTBridgeMethod>> *methods;
|
|
|
|
/**
|
|
* Returns the module's constants, if it exports any
|
|
*/
|
|
@property (nonatomic, copy, readonly) NSDictionary<NSString *, id> *exportedConstants;
|
|
|
|
/**
|
|
* Returns YES if module instance has already been initialized; NO otherwise.
|
|
*/
|
|
@property (nonatomic, assign, readonly) BOOL hasInstance;
|
|
|
|
/**
|
|
* Returns YES if module instance must be created on the main thread.
|
|
*/
|
|
@property (nonatomic, assign) BOOL requiresMainQueueSetup;
|
|
|
|
/**
|
|
* Returns YES if module has constants to export.
|
|
*/
|
|
@property (nonatomic, assign, readonly) BOOL hasConstantsToExport;
|
|
|
|
/**
|
|
* Returns the current module instance. Note that this will init the instance
|
|
* if it has not already been created. To check if the module instance exists
|
|
* without causing it to be created, use `hasInstance` instead.
|
|
*/
|
|
@property (nonatomic, strong, readwrite) id<RCTBridgeModule> instance;
|
|
|
|
/**
|
|
* Returns the module method dispatch queue. Note that this will init both the
|
|
* queue and the module itself if they have not already been created.
|
|
*/
|
|
@property (nonatomic, strong, readonly) dispatch_queue_t methodQueue;
|
|
|
|
/**
|
|
* Whether the receiver has a valid `instance` which implements -batchDidComplete.
|
|
*/
|
|
@property (nonatomic, assign, readonly) BOOL implementsBatchDidComplete;
|
|
|
|
/**
|
|
* Whether the receiver has a valid `instance` which implements
|
|
* -partialBatchDidFlush.
|
|
*/
|
|
@property (nonatomic, assign, readonly) BOOL implementsPartialBatchDidFlush;
|
|
|
|
@end
|