diff --git a/doric-iOS/Pod/Classes/Resource/DoricResource.h b/doric-iOS/Pod/Classes/Resource/DoricResource.h index e65b2333..b9b77801 100644 --- a/doric-iOS/Pod/Classes/Resource/DoricResource.h +++ b/doric-iOS/Pod/Classes/Resource/DoricResource.h @@ -29,4 +29,6 @@ - (instancetype)initWithContext:(DoricContext *)context identifier:(NSString *)identifier; - (DoricAsyncResult *)fetchRaw; + +- (DoricAsyncResult *)fetch; @end \ No newline at end of file diff --git a/doric-iOS/Pod/Classes/Resource/DoricResource.m b/doric-iOS/Pod/Classes/Resource/DoricResource.m index f8c988b1..6f298770 100644 --- a/doric-iOS/Pod/Classes/Resource/DoricResource.m +++ b/doric-iOS/Pod/Classes/Resource/DoricResource.m @@ -19,6 +19,10 @@ #import "DoricResource.h" +@interface DoricResource () +@property(nonatomic, strong) DoricAsyncResult *result; +@end + @implementation DoricResource - (instancetype)initWithContext:(DoricContext *)context identifier:(NSString *)identifier { if (self = [super init]) { @@ -27,7 +31,15 @@ - (instancetype)initWithContext:(DoricContext *)context identifier:(NSString *)i } return self; } + - (DoricAsyncResult *)fetchRaw { return nil; } + +- (DoricAsyncResult *)fetch { + if (!self.result) { + self.result = [self fetchRaw]; + } + return self.result; +} @end diff --git a/doric-iOS/Pod/Classes/Shader/DoricImageNode.m b/doric-iOS/Pod/Classes/Shader/DoricImageNode.m index e3306974..c7ea0a37 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricImageNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricImageNode.m @@ -238,7 +238,7 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id if ([@"image" isEqualToString:name]) { DoricAsyncResult *asyncResult = [[self.doricContext.driver.registry.loaderManager load:prop - withContext:self.doricContext] fetchRaw]; + withContext:self.doricContext] fetch]; [asyncResult setResultCallback:^(NSData *imageData) { [self.doricContext dispatchToMainQueue:^{ #if DORIC_USE_YYWEBIMAGE