YH_ModuleData.h
2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
// YH_ModuleData.h
// YH_WatchDog
//
// Created by redding on 16/3/7.
// Copyright © 2016年 YOHO. All rights reserved.
//
#import <Foundation/Foundation.h>
@protocol YH_BridgeModule;
@protocol YH_BridgeService;
@class YH_WatchDog;
@interface YH_ModuleData : NSObject
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithModuleClass:(Class)moduleClass bridge:(YH_WatchDog *)bridge NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithModuleInstance:(id<YH_BridgeModule>)instance bridge:(YH_WatchDog *)bridge;
/**
* Sets the bridge for the module instance. This is only needed when using the
* `initWithModuleInstance:bridge:` constructor. Otherwise, the bridge will be set
* automatically when the module is first accessed.
*/
- (void)setBridgeForInstance;
/**
* Sets the methodQueue and performs the remaining setup for the module. This is
* only needed when using the `initWithModuleInstance:bridge:` constructor.
* Otherwise it will be done automatically when the module is first accessed.
*/
- (void)finishSetupForInstance;
@property (nonatomic, strong, readonly) Class moduleClass;
@property (nonatomic, copy, readonly) NSString *name;
/**
* Returns the module services. Note that this will gather the services the first
* time it is called and then memoize the results.
*/
@property (nonatomic, copy, readonly) NSDictionary<NSString *, id<YH_BridgeService>> *services;
/**
* Returns YES if module instance has already been initialized; NO otherwise.
*/
@property (nonatomic, assign, readonly) BOOL hasInstance;
/**
* 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, readonly) id<YH_BridgeModule> 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 serviceQueue;
- (NSString *)debugDescription;
@end