feat:iOS DoricResult add fetch cache
This commit is contained in:
parent
7978900a4f
commit
6ecfc307bf
@ -29,4 +29,6 @@
|
||||
- (instancetype)initWithContext:(DoricContext *)context identifier:(NSString *)identifier;
|
||||
|
||||
- (DoricAsyncResult <NSData *> *)fetchRaw;
|
||||
|
||||
- (DoricAsyncResult <NSData *> *)fetch;
|
||||
@end
|
@ -19,6 +19,10 @@
|
||||
|
||||
#import "DoricResource.h"
|
||||
|
||||
@interface DoricResource ()
|
||||
@property(nonatomic, strong) DoricAsyncResult<NSData *> *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<NSData *> *)fetchRaw {
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (DoricAsyncResult <NSData *> *)fetch {
|
||||
if (!self.result) {
|
||||
self.result = [self fetchRaw];
|
||||
}
|
||||
return self.result;
|
||||
}
|
||||
@end
|
||||
|
@ -238,7 +238,7 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id
|
||||
if ([@"image" isEqualToString:name]) {
|
||||
DoricAsyncResult <NSData *> *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
|
||||
|
Reference in New Issue
Block a user