feat:add pureCallEntityMethod,avoid hook affects
This commit is contained in:
@@ -237,7 +237,7 @@ - (NSDictionary *)itemModelAt:(NSUInteger)position {
|
||||
if (viewId && viewId.length > 0) {
|
||||
return [self subModelOf:viewId];
|
||||
} else {
|
||||
DoricAsyncResult *result = [self callJSResponse:@"renderBunchedItems", @(position), @(self.batchCount), nil];
|
||||
DoricAsyncResult *result = [self pureCallJSResponse:@"renderBunchedItems", @(position), @(self.batchCount), nil];
|
||||
NSArray *array = [result waitUntilResult:^(JSValue *models) {
|
||||
return [models toArray];
|
||||
}];
|
||||
|
@@ -190,7 +190,7 @@ - (NSDictionary *)itemModelAt:(NSUInteger)position {
|
||||
start--;
|
||||
batchCount++;
|
||||
}
|
||||
DoricAsyncResult *result = [self callJSResponse:@"renderBunchedItems", @(start), @(batchCount), nil];
|
||||
DoricAsyncResult *result = [self pureCallJSResponse:@"renderBunchedItems", @(start), @(batchCount), nil];
|
||||
NSArray *array = [result waitUntilResult:^(JSValue *models) {
|
||||
return [models toArray];
|
||||
}];
|
||||
|
@@ -158,12 +158,12 @@ - (NSDictionary *)itemModelAt:(NSUInteger)position {
|
||||
} else {
|
||||
index = position;
|
||||
}
|
||||
|
||||
|
||||
NSString *viewId = self.itemViewIds[@(index)];
|
||||
if (viewId && viewId.length > 0) {
|
||||
return [self subModelOf:viewId];
|
||||
} else {
|
||||
DoricAsyncResult *result = [self callJSResponse:@"renderBunchedItems", @(index), @(self.batchCount), nil];
|
||||
DoricAsyncResult *result = [self pureCallJSResponse:@"renderBunchedItems", @(index), @(self.batchCount), nil];
|
||||
NSArray *array = [result waitUntilResult:^(JSValue *models) {
|
||||
return [models toArray];
|
||||
}];
|
||||
@@ -217,7 +217,7 @@ - (void)blendSubNode:(NSDictionary *)subModel {
|
||||
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
|
||||
NSUInteger pageIndex = (NSUInteger) (scrollView.contentOffset.x / scrollView.width);
|
||||
scrollView.contentOffset = CGPointMake(pageIndex * scrollView.width, scrollView.contentOffset.y);
|
||||
|
||||
|
||||
if (self.loop) {
|
||||
if (pageIndex == 0) {
|
||||
[self.view setContentOffset:CGPointMake(self.itemCount * self.view.width, self.view.contentOffset.y) animated:false];
|
||||
@@ -225,7 +225,7 @@ - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
|
||||
[self.view setContentOffset:CGPointMake(1 * self.view.width, self.view.contentOffset.y) animated:false];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (self.onPageSelectedFuncId && self.onPageSelectedFuncId.length > 0) {
|
||||
if (pageIndex != self.lastPosition) {
|
||||
[self callJSResponse:self.onPageSelectedFuncId, @(pageIndex), nil];
|
||||
|
@@ -48,6 +48,8 @@
|
||||
|
||||
- (DoricAsyncResult *)callJSResponse:(NSString *)funcId, ...;
|
||||
|
||||
- (DoricAsyncResult *)pureCallJSResponse:(NSString *)funcId, ...;
|
||||
|
||||
+ (__kindof DoricViewNode *)create:(DoricContext *)context withType:(NSString *)type;
|
||||
|
||||
- (void)requestLayout;
|
||||
|
@@ -292,6 +292,30 @@ - (DoricAsyncResult *)callJSResponse:(NSString *)funcId, ... {
|
||||
return ret;
|
||||
}
|
||||
|
||||
- (DoricAsyncResult *)pureCallJSResponse:(NSString *)funcId, ... {
|
||||
NSMutableArray *array = [[NSMutableArray alloc] init];
|
||||
[array addObject:self.doricContext.contextId];
|
||||
[array addObject:DORIC_ENTITY_RESPONSE];
|
||||
[array addObject:self.idList];
|
||||
[array addObject:funcId];
|
||||
va_list args;
|
||||
va_start(args, funcId);
|
||||
id arg;
|
||||
while ((arg = va_arg(args, id)) != nil) {
|
||||
[array addObject:arg];
|
||||
}
|
||||
DoricAsyncResult *ret = [self.doricContext.driver invokeDoricMethod:DORIC_CONTEXT_INVOKE_PURE argumentsArray:array];
|
||||
__weak typeof(self) __self = self;
|
||||
ret.exceptionCallback = ^(NSException *e) {
|
||||
__strong typeof(__self) self = __self;
|
||||
[self.doricContext.driver.registry
|
||||
onException:e
|
||||
inContext:self.doricContext];
|
||||
};
|
||||
va_end(args);
|
||||
return ret;
|
||||
}
|
||||
|
||||
+ (__kindof DoricViewNode *)create:(DoricContext *)context withType:(NSString *)type {
|
||||
DoricRegistry *registry = context.driver.registry;
|
||||
Class clz = [registry acquireViewNode:type];
|
||||
|
@@ -46,6 +46,8 @@ extern NSString *const DORIC_CONTEXT_RELEASE;
|
||||
|
||||
extern NSString *const DORIC_CONTEXT_INVOKE;
|
||||
|
||||
extern NSString *const DORIC_CONTEXT_INVOKE_PURE;
|
||||
|
||||
extern NSString *const DORIC_TIMER_CALLBACK;
|
||||
|
||||
extern NSString *const DORIC_BRIDGE_RESOLVE;
|
||||
|
@@ -64,6 +64,8 @@
|
||||
|
||||
NSString *const DORIC_CONTEXT_INVOKE = @"jsCallEntityMethod";
|
||||
|
||||
NSString *const DORIC_CONTEXT_INVOKE_PURE = @"pureCallEntityMethod";
|
||||
|
||||
NSString *const DORIC_TIMER_CALLBACK = @"jsCallbackTimer";
|
||||
|
||||
NSString *const DORIC_BRIDGE_RESOLVE = @"jsCallResolve";
|
||||
|
Reference in New Issue
Block a user