refact:compat DoricJSLoaderManager api

This commit is contained in:
pengfei.zhou 2021-07-21 18:08:45 +08:00 committed by osborn
parent 844908bdc6
commit c7de1f90e2
3 changed files with 13 additions and 0 deletions

View File

@ -23,6 +23,7 @@ import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import pub.doric.DoricSingleton;
import pub.doric.async.AsyncResult; import pub.doric.async.AsyncResult;
/** /**
@ -68,4 +69,8 @@ public class DoricJSLoaderManager {
return ret; return ret;
} }
public static DoricJSLoaderManager getInstance() {
return DoricSingleton.getInstance().getJsLoaderManager();
}
} }

View File

@ -25,6 +25,8 @@
#import "DoricAsyncResult.h" #import "DoricAsyncResult.h"
@interface DoricJSLoaderManager : NSObject @interface DoricJSLoaderManager : NSObject
+ (instancetype)instance;
- (void)addJSLoader:(id <DoricLoaderProtocol>)loader; - (void)addJSLoader:(id <DoricLoaderProtocol>)loader;
- (DoricAsyncResult <NSString *> *)request:(NSString *)source; - (DoricAsyncResult <NSString *> *)request:(NSString *)source;

View File

@ -24,12 +24,18 @@
#import "DoricMainBundleJSLoader.h" #import "DoricMainBundleJSLoader.h"
#import "DoricHttpJSLoader.h" #import "DoricHttpJSLoader.h"
#import "Doric.h" #import "Doric.h"
#import "DoricSingleton.h"
@interface DoricJSLoaderManager () @interface DoricJSLoaderManager ()
@property(nonatomic, copy) NSSet <id <DoricLoaderProtocol>> *loaders; @property(nonatomic, copy) NSSet <id <DoricLoaderProtocol>> *loaders;
@end @end
@implementation DoricJSLoaderManager @implementation DoricJSLoaderManager
+ (instancetype)instance {
return DoricSingleton.instance.jsLoaderManager;
}
- (instancetype)init { - (instancetype)init {
if (self = [super init]) { if (self = [super init]) {
_loaders = [[NSSet alloc] initWithArray:@[ _loaders = [[NSSet alloc] initWithArray:@[