refact: use DoricSingleton to hold all static or singleton objects

This commit is contained in:
pengfei.zhou
2021-07-21 17:56:03 +08:00
committed by osborn
parent 7d4d6713c6
commit 61c262bcc6
30 changed files with 320 additions and 221 deletions

View File

@@ -27,12 +27,13 @@
#import "DoricExtensions.h"
#import "DoricNativeDriver.h"
#import "DoricUtil.h"
#import "DoricSingleton.h"
@implementation DoricContext
- (instancetype)initWithScript:(NSString *)script source:(NSString *)source extra:(NSString *)extra {
if (self = [super init]) {
_driver = [DoricNativeDriver instance];
_driver = DoricSingleton.instance.nativeDriver;
_pluginInstanceMap = [NSMutableDictionary new];
_script = script;
_source = source;
@@ -84,7 +85,7 @@ - (DoricAsyncResult *)callEntity:(NSString *)method withArgumentsArray:(NSArray
}
- (void)init:(NSString *)initData {
if ([DoricRegistry isEnableRenderSnapshot]) {
if (DoricSingleton.instance.enableRecordSnapshot) {
[self callEntity:@"__enableSnapshot__" withArgumentsArray:@[]];
}
self.extra = initData;
@@ -135,7 +136,6 @@ - (UIViewController *)vc {
return _vc;
}
- (void)dispatchToMainQueue:(_Nonnull dispatch_block_t)block {
dispatch_async(dispatch_get_main_queue(), ^{
@try {