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;
|
- (instancetype)initWithContext:(DoricContext *)context identifier:(NSString *)identifier;
|
||||||
|
|
||||||
- (DoricAsyncResult <NSData *> *)fetchRaw;
|
- (DoricAsyncResult <NSData *> *)fetchRaw;
|
||||||
|
|
||||||
|
- (DoricAsyncResult <NSData *> *)fetch;
|
||||||
@end
|
@end
|
@ -19,6 +19,10 @@
|
|||||||
|
|
||||||
#import "DoricResource.h"
|
#import "DoricResource.h"
|
||||||
|
|
||||||
|
@interface DoricResource ()
|
||||||
|
@property(nonatomic, strong) DoricAsyncResult<NSData *> *result;
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation DoricResource
|
@implementation DoricResource
|
||||||
- (instancetype)initWithContext:(DoricContext *)context identifier:(NSString *)identifier {
|
- (instancetype)initWithContext:(DoricContext *)context identifier:(NSString *)identifier {
|
||||||
if (self = [super init]) {
|
if (self = [super init]) {
|
||||||
@ -27,7 +31,15 @@ - (instancetype)initWithContext:(DoricContext *)context identifier:(NSString *)i
|
|||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (DoricAsyncResult<NSData *> *)fetchRaw {
|
- (DoricAsyncResult<NSData *> *)fetchRaw {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (DoricAsyncResult <NSData *> *)fetch {
|
||||||
|
if (!self.result) {
|
||||||
|
self.result = [self fetchRaw];
|
||||||
|
}
|
||||||
|
return self.result;
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
@ -238,7 +238,7 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id
|
|||||||
if ([@"image" isEqualToString:name]) {
|
if ([@"image" isEqualToString:name]) {
|
||||||
DoricAsyncResult <NSData *> *asyncResult = [[self.doricContext.driver.registry.loaderManager
|
DoricAsyncResult <NSData *> *asyncResult = [[self.doricContext.driver.registry.loaderManager
|
||||||
load:prop
|
load:prop
|
||||||
withContext:self.doricContext] fetchRaw];
|
withContext:self.doricContext] fetch];
|
||||||
[asyncResult setResultCallback:^(NSData *imageData) {
|
[asyncResult setResultCallback:^(NSData *imageData) {
|
||||||
[self.doricContext dispatchToMainQueue:^{
|
[self.doricContext dispatchToMainQueue:^{
|
||||||
#if DORIC_USE_YYWEBIMAGE
|
#if DORIC_USE_YYWEBIMAGE
|
||||||
|
Reference in New Issue
Block a user