feat:avoid iOS dealloc JSValue in main thread,this may cause crash in JavaScriptCore

This commit is contained in:
pengfeizhou
2021-01-06 11:56:30 +08:00
committed by osborn
parent 967ad27a22
commit 2100eff054
7 changed files with 29 additions and 8 deletions

View File

@@ -237,8 +237,9 @@ - (NSDictionary *)itemModelAt:(NSUInteger)position {
return [self subModelOf:viewId];
} else {
DoricAsyncResult *result = [self callJSResponse:@"renderBunchedItems", @(position), @(self.batchCount), nil];
JSValue *models = [result waitUntilResult];
NSArray *array = [models toArray];
NSArray *array = [result waitUntilResult:^(JSValue *models) {
return [models toArray];
}];
[array enumerateObjectsUsingBlock:^(NSDictionary *obj, NSUInteger idx, BOOL *stop) {
NSString *thisViewId = obj[@"id"];
[self setSubModel:obj in:thisViewId];

View File

@@ -178,8 +178,9 @@ - (NSDictionary *)itemModelAt:(NSUInteger)position {
batchCount++;
}
DoricAsyncResult *result = [self callJSResponse:@"renderBunchedItems", @(start), @(batchCount), nil];
JSValue *models = [result waitUntilResult];
NSArray *array = [models toArray];
NSArray *array = [result waitUntilResult:^(JSValue *models) {
return [models toArray];
}];
[array enumerateObjectsUsingBlock:^(NSDictionary *obj, NSUInteger idx, BOOL *stop) {
NSString *thisViewId = obj[@"id"];
[self setSubModel:obj in:thisViewId];

View File

@@ -164,8 +164,9 @@ - (NSDictionary *)itemModelAt:(NSUInteger)position {
return [self subModelOf:viewId];
} else {
DoricAsyncResult *result = [self callJSResponse:@"renderBunchedItems", @(index), @(self.batchCount), nil];
JSValue *models = [result waitUntilResult];
NSArray *array = [models toArray];
NSArray *array = [result waitUntilResult:^(JSValue *models) {
return [models toArray];
}];
[array enumerateObjectsUsingBlock:^(NSDictionary *obj, NSUInteger idx, BOOL *stop) {
NSString *thisViewId = obj[@"id"];
[self setSubModel:obj in:thisViewId];