feat:add pureCallEntityMethod,avoid hook affects

This commit is contained in:
pengfei.zhou 2021-04-14 16:53:38 +08:00 committed by osborn
parent b762b9db4b
commit 009e8734b6
37 changed files with 266 additions and 209 deletions

View File

@ -567,6 +567,36 @@ public abstract class ViewNode<T extends View> extends DoricContextHolder {
return getDoricContext().callEntity(DoricConstant.DORIC_ENTITY_RESPONSE, nArgs); return getDoricContext().callEntity(DoricConstant.DORIC_ENTITY_RESPONSE, nArgs);
} }
public AsyncResult<JSDecoder> pureCallJSResponse(String funcId, Object... args) {
final Object[] nArgs = new Object[args.length + 4];
nArgs[0] = getDoricContext().getContextId();
nArgs[1] = DoricConstant.DORIC_ENTITY_RESPONSE;
nArgs[2] = getIdList();
nArgs[3] = funcId;
if (args.length > 0) {
System.arraycopy(args, 0, nArgs, 4, args.length);
}
final AsyncResult<JSDecoder> asyncResult = new AsyncResult<>();
getDoricContext().getDriver().invokeDoricMethod(DoricConstant.DORIC_CONTEXT_INVOKE_PURE, nArgs).setCallback(new AsyncResult.Callback<JSDecoder>() {
@Override
public void onResult(JSDecoder result) {
asyncResult.setResult(result);
}
@Override
public void onError(Throwable t) {
getDoricContext().getDriver().getRegistry().onException(getDoricContext(), t instanceof Exception ? (Exception) t : new RuntimeException(t));
asyncResult.setError(t);
}
@Override
public void onFinish() {
}
});
return asyncResult;
}
public static ViewNode create(DoricContext doricContext, String type) { public static ViewNode create(DoricContext doricContext, String type) {
DoricRegistry registry = doricContext.getDriver().getRegistry(); DoricRegistry registry = doricContext.getDriver().getRegistry();
DoricMetaInfo<ViewNode> clz = registry.acquireViewNodeInfo(type); DoricMetaInfo<ViewNode> clz = registry.acquireViewNodeInfo(type);

View File

@ -103,7 +103,7 @@ class FlowAdapter extends RecyclerView.Adapter<FlowAdapter.DoricViewHolder> {
} }
String id = itemValues.get(position); String id = itemValues.get(position);
if (TextUtils.isEmpty(id)) { if (TextUtils.isEmpty(id)) {
AsyncResult<JSDecoder> asyncResult = flowLayoutNode.callJSResponse( AsyncResult<JSDecoder> asyncResult = flowLayoutNode.pureCallJSResponse(
"renderBunchedItems", "renderBunchedItems",
position, position,
batchCount); batchCount);

View File

@ -103,7 +103,7 @@ class ListAdapter extends RecyclerView.Adapter<ListAdapter.DoricViewHolder> {
start--; start--;
batchCount++; batchCount++;
} }
AsyncResult<JSDecoder> asyncResult = listNode.callJSResponse( AsyncResult<JSDecoder> asyncResult = listNode.pureCallJSResponse(
"renderBunchedItems", "renderBunchedItems",
start, start,
batchCount); batchCount);

View File

@ -105,7 +105,7 @@ class SlideAdapter extends RecyclerView.Adapter<SlideAdapter.DoricViewHolder> {
String id = itemValues.get(index); String id = itemValues.get(index);
if (TextUtils.isEmpty(id)) { if (TextUtils.isEmpty(id)) {
AsyncResult<JSDecoder> asyncResult = sliderNode.callJSResponse( AsyncResult<JSDecoder> asyncResult = sliderNode.pureCallJSResponse(
"renderBunchedItems", "renderBunchedItems",
index, index,
batchCount); batchCount);

View File

@ -59,6 +59,8 @@ public class DoricConstant {
public static final String GLOBAL_DORIC = "doric"; public static final String GLOBAL_DORIC = "doric";
public static final String DORIC_CONTEXT_RELEASE = "jsReleaseContext"; public static final String DORIC_CONTEXT_RELEASE = "jsReleaseContext";
public static final String DORIC_CONTEXT_INVOKE = "jsCallEntityMethod"; public static final String DORIC_CONTEXT_INVOKE = "jsCallEntityMethod";
public static final String DORIC_CONTEXT_INVOKE_PURE = "pureCallEntityMethod";
public static final String DORIC_TIMER_CALLBACK = "jsCallbackTimer"; public static final String DORIC_TIMER_CALLBACK = "jsCallbackTimer";
public static final String DORIC_BRIDGE_RESOLVE = "jsCallResolve"; public static final String DORIC_BRIDGE_RESOLVE = "jsCallResolve";
public static final String DORIC_BRIDGE_REJECT = "jsCallReject"; public static final String DORIC_BRIDGE_REJECT = "jsCallReject";

View File

@ -50,9 +50,9 @@ class ListVH extends ViewHolder {
itemCount: 0, itemCount: 0,
layoutConfig: { layoutConfig: {
widthSpec: LayoutSpec.MOST, widthSpec: LayoutSpec.MOST,
heightSpec: LayoutSpec.FIT, heightSpec: LayoutSpec.JUST,
weight: 1
}, },
backgroundColor: Color.YELLOW,
}) })
], ],
{ {

View File

@ -237,7 +237,7 @@ - (NSDictionary *)itemModelAt:(NSUInteger)position {
if (viewId && viewId.length > 0) { if (viewId && viewId.length > 0) {
return [self subModelOf:viewId]; return [self subModelOf:viewId];
} else { } 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) { NSArray *array = [result waitUntilResult:^(JSValue *models) {
return [models toArray]; return [models toArray];
}]; }];

View File

@ -190,7 +190,7 @@ - (NSDictionary *)itemModelAt:(NSUInteger)position {
start--; start--;
batchCount++; batchCount++;
} }
DoricAsyncResult *result = [self callJSResponse:@"renderBunchedItems", @(start), @(batchCount), nil]; DoricAsyncResult *result = [self pureCallJSResponse:@"renderBunchedItems", @(start), @(batchCount), nil];
NSArray *array = [result waitUntilResult:^(JSValue *models) { NSArray *array = [result waitUntilResult:^(JSValue *models) {
return [models toArray]; return [models toArray];
}]; }];

View File

@ -163,7 +163,7 @@ - (NSDictionary *)itemModelAt:(NSUInteger)position {
if (viewId && viewId.length > 0) { if (viewId && viewId.length > 0) {
return [self subModelOf:viewId]; return [self subModelOf:viewId];
} else { } 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) { NSArray *array = [result waitUntilResult:^(JSValue *models) {
return [models toArray]; return [models toArray];
}]; }];

View File

@ -48,6 +48,8 @@
- (DoricAsyncResult *)callJSResponse:(NSString *)funcId, ...; - (DoricAsyncResult *)callJSResponse:(NSString *)funcId, ...;
- (DoricAsyncResult *)pureCallJSResponse:(NSString *)funcId, ...;
+ (__kindof DoricViewNode *)create:(DoricContext *)context withType:(NSString *)type; + (__kindof DoricViewNode *)create:(DoricContext *)context withType:(NSString *)type;
- (void)requestLayout; - (void)requestLayout;

View File

@ -292,6 +292,30 @@ - (DoricAsyncResult *)callJSResponse:(NSString *)funcId, ... {
return ret; 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 { + (__kindof DoricViewNode *)create:(DoricContext *)context withType:(NSString *)type {
DoricRegistry *registry = context.driver.registry; DoricRegistry *registry = context.driver.registry;
Class clz = [registry acquireViewNode:type]; Class clz = [registry acquireViewNode:type];

View File

@ -46,6 +46,8 @@ extern NSString *const DORIC_CONTEXT_RELEASE;
extern NSString *const DORIC_CONTEXT_INVOKE; extern NSString *const DORIC_CONTEXT_INVOKE;
extern NSString *const DORIC_CONTEXT_INVOKE_PURE;
extern NSString *const DORIC_TIMER_CALLBACK; extern NSString *const DORIC_TIMER_CALLBACK;
extern NSString *const DORIC_BRIDGE_RESOLVE; extern NSString *const DORIC_BRIDGE_RESOLVE;

View File

@ -64,6 +64,8 @@
NSString *const DORIC_CONTEXT_INVOKE = @"jsCallEntityMethod"; NSString *const DORIC_CONTEXT_INVOKE = @"jsCallEntityMethod";
NSString *const DORIC_CONTEXT_INVOKE_PURE = @"pureCallEntityMethod";
NSString *const DORIC_TIMER_CALLBACK = @"jsCallbackTimer"; NSString *const DORIC_TIMER_CALLBACK = @"jsCallbackTimer";
NSString *const DORIC_BRIDGE_RESOLVE = @"jsCallResolve"; NSString *const DORIC_BRIDGE_RESOLVE = @"jsCallResolve";

View File

@ -2032,7 +2032,6 @@ var List = /** @class */ (function (_super) {
function List() { function List() {
var _this = _super !== null && _super.apply(this, arguments) || this; var _this = _super !== null && _super.apply(this, arguments) || this;
_this.cachedViews = new Map; _this.cachedViews = new Map;
_this.ignoreDirtyCallOnce = false;
_this.itemCount = 0; _this.itemCount = 0;
_this.batchCount = 15; _this.batchCount = 15;
return _this; return _this;
@ -2059,17 +2058,8 @@ var List = /** @class */ (function (_super) {
this.cachedViews.set("" + itemIdx, view); this.cachedViews.set("" + itemIdx, view);
return view; return view;
}; };
List.prototype.isDirty = function () {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return _super.prototype.isDirty.call(this);
};
List.prototype.renderBunchedItems = function (start, length) { List.prototype.renderBunchedItems = function (start, length) {
var _this = this; var _this = this;
this.ignoreDirtyCallOnce = true;
return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map(function (_, idx) { return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map(function (_, idx) {
var listItem = _this.getItem(start + idx); var listItem = _this.getItem(start + idx);
return listItem.toModel(); return listItem.toModel();
@ -2185,7 +2175,6 @@ var Slider = /** @class */ (function (_super) {
function Slider() { function Slider() {
var _this = _super !== null && _super.apply(this, arguments) || this; var _this = _super !== null && _super.apply(this, arguments) || this;
_this.cachedViews = new Map; _this.cachedViews = new Map;
_this.ignoreDirtyCallOnce = false;
_this.itemCount = 0; _this.itemCount = 0;
_this.batchCount = 3; _this.batchCount = 3;
return _this; return _this;
@ -2199,17 +2188,8 @@ var Slider = /** @class */ (function (_super) {
this.cachedViews.set("" + itemIdx, view); this.cachedViews.set("" + itemIdx, view);
return view; return view;
}; };
Slider.prototype.isDirty = function () {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return _super.prototype.isDirty.call(this);
};
Slider.prototype.renderBunchedItems = function (start, length) { Slider.prototype.renderBunchedItems = function (start, length) {
var _this = this; var _this = this;
this.ignoreDirtyCallOnce = true;
return new Array(Math.min(length, this.itemCount - start)).fill(0).map(function (_, idx) { return new Array(Math.min(length, this.itemCount - start)).fill(0).map(function (_, idx) {
var slideItem = _this.getItem(start + idx); var slideItem = _this.getItem(start + idx);
return slideItem.toModel(); return slideItem.toModel();
@ -2560,7 +2540,6 @@ var FlowLayout = /** @class */ (function (_super) {
function FlowLayout() { function FlowLayout() {
var _this = _super !== null && _super.apply(this, arguments) || this; var _this = _super !== null && _super.apply(this, arguments) || this;
_this.cachedViews = new Map; _this.cachedViews = new Map;
_this.ignoreDirtyCallOnce = false;
_this.columnCount = 2; _this.columnCount = 2;
_this.itemCount = 0; _this.itemCount = 0;
_this.batchCount = 15; _this.batchCount = 15;
@ -2584,17 +2563,8 @@ var FlowLayout = /** @class */ (function (_super) {
this.cachedViews.set("" + itemIdx, view); this.cachedViews.set("" + itemIdx, view);
return view; return view;
}; };
FlowLayout.prototype.isDirty = function () {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return _super.prototype.isDirty.call(this);
};
FlowLayout.prototype.renderBunchedItems = function (start, length) { FlowLayout.prototype.renderBunchedItems = function (start, length) {
var _this = this; var _this = this;
this.ignoreDirtyCallOnce = true;
return new Array(Math.min(length, this.itemCount - start)).fill(0).map(function (_, idx) { return new Array(Math.min(length, this.itemCount - start)).fill(0).map(function (_, idx) {
var listItem = _this.getItem(start + idx); var listItem = _this.getItem(start + idx);
return listItem.toModel(); return listItem.toModel();

View File

@ -1531,7 +1531,6 @@ class List extends Superview {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.cachedViews = new Map; this.cachedViews = new Map;
this.ignoreDirtyCallOnce = false;
this.itemCount = 0; this.itemCount = 0;
this.batchCount = 15; this.batchCount = 15;
} }
@ -1557,16 +1556,7 @@ class List extends Superview {
this.cachedViews.set(`${itemIdx}`, view); this.cachedViews.set(`${itemIdx}`, view);
return view; return view;
} }
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return super.isDirty();
}
renderBunchedItems(start, length) { renderBunchedItems(start, length) {
this.ignoreDirtyCallOnce = true;
return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map((_, idx) => { return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map((_, idx) => {
const listItem = this.getItem(start + idx); const listItem = this.getItem(start + idx);
return listItem.toModel(); return listItem.toModel();
@ -1660,7 +1650,6 @@ class Slider extends Superview {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.cachedViews = new Map; this.cachedViews = new Map;
this.ignoreDirtyCallOnce = false;
this.itemCount = 0; this.itemCount = 0;
this.batchCount = 3; this.batchCount = 3;
} }
@ -1673,16 +1662,7 @@ class Slider extends Superview {
this.cachedViews.set(`${itemIdx}`, view); this.cachedViews.set(`${itemIdx}`, view);
return view; return view;
} }
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return super.isDirty();
}
renderBunchedItems(start, length) { renderBunchedItems(start, length) {
this.ignoreDirtyCallOnce = true;
return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => { return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => {
const slideItem = this.getItem(start + idx); const slideItem = this.getItem(start + idx);
return slideItem.toModel(); return slideItem.toModel();
@ -1948,7 +1928,6 @@ class FlowLayout extends Superview {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.cachedViews = new Map; this.cachedViews = new Map;
this.ignoreDirtyCallOnce = false;
this.columnCount = 2; this.columnCount = 2;
this.itemCount = 0; this.itemCount = 0;
this.batchCount = 15; this.batchCount = 15;
@ -1971,16 +1950,7 @@ class FlowLayout extends Superview {
this.cachedViews.set(`${itemIdx}`, view); this.cachedViews.set(`${itemIdx}`, view);
return view; return view;
} }
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return super.isDirty();
}
renderBunchedItems(start, length) { renderBunchedItems(start, length) {
this.ignoreDirtyCallOnce = true;
return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => { return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => {
const listItem = this.getItem(start + idx); const listItem = this.getItem(start + idx);
return listItem.toModel(); return listItem.toModel();

View File

@ -1398,6 +1398,29 @@ var doric = (function (exports) {
loge("Cannot find method for context id:" + contextId + ",method name is:" + methodName); loge("Cannot find method for context id:" + contextId + ",method name is:" + methodName);
} }
} }
function pureCallEntityMethod(contextId, methodName, args) {
var arguments$1 = arguments;
var context = gContexts.get(contextId);
if (context === undefined) {
loge("Cannot find context for context id:" + contextId);
return;
}
if (context.entity === undefined) {
loge("Cannot find holder for context id:" + contextId);
return;
}
if (Reflect.has(context.entity, methodName)) {
var argumentsList = [];
for (var i = 2; i < arguments.length; i++) {
argumentsList.push(arguments$1[i]);
}
return Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList);
}
else {
loge("Cannot find method for context id:" + contextId + ",method name is:" + methodName);
}
}
function jsObtainEntry(contextId) { function jsObtainEntry(contextId) {
var context = jsObtainContext(contextId); var context = jsObtainContext(contextId);
var exportFunc = function (constructor) { var exportFunc = function (constructor) {
@ -13775,6 +13798,7 @@ var doric = (function (exports) {
exports.jsObtainEntry = jsObtainEntry; exports.jsObtainEntry = jsObtainEntry;
exports.jsRegisterModule = jsRegisterModule; exports.jsRegisterModule = jsRegisterModule;
exports.jsReleaseContext = jsReleaseContext; exports.jsReleaseContext = jsReleaseContext;
exports.pureCallEntityMethod = pureCallEntityMethod;
Object.defineProperty(exports, '__esModule', { value: true }); Object.defineProperty(exports, '__esModule', { value: true });

View File

@ -1397,6 +1397,27 @@ var doric = (function (exports) {
loge(`Cannot find method for context id:${contextId},method name is:${methodName}`); loge(`Cannot find method for context id:${contextId},method name is:${methodName}`);
} }
} }
function pureCallEntityMethod(contextId, methodName, args) {
const context = gContexts.get(contextId);
if (context === undefined) {
loge(`Cannot find context for context id:${contextId}`);
return;
}
if (context.entity === undefined) {
loge(`Cannot find holder for context id:${contextId}`);
return;
}
if (Reflect.has(context.entity, methodName)) {
const argumentsList = [];
for (let i = 2; i < arguments.length; i++) {
argumentsList.push(arguments[i]);
}
return Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList);
}
else {
loge(`Cannot find method for context id:${contextId},method name is:${methodName}`);
}
}
function jsObtainEntry(contextId) { function jsObtainEntry(contextId) {
const context = jsObtainContext(contextId); const context = jsObtainContext(contextId);
const exportFunc = (constructor) => { const exportFunc = (constructor) => {
@ -1538,6 +1559,7 @@ var doric = (function (exports) {
exports.jsObtainEntry = jsObtainEntry; exports.jsObtainEntry = jsObtainEntry;
exports.jsRegisterModule = jsRegisterModule; exports.jsRegisterModule = jsRegisterModule;
exports.jsReleaseContext = jsReleaseContext; exports.jsReleaseContext = jsReleaseContext;
exports.pureCallEntityMethod = pureCallEntityMethod;
Object.defineProperty(exports, '__esModule', { value: true }); Object.defineProperty(exports, '__esModule', { value: true });

View File

@ -1426,6 +1426,27 @@ function jsCallEntityMethod(contextId, methodName, args) {
loge(`Cannot find method for context id:${contextId},method name is:${methodName}`); loge(`Cannot find method for context id:${contextId},method name is:${methodName}`);
} }
} }
function pureCallEntityMethod(contextId, methodName, args) {
const context = gContexts.get(contextId);
if (context === undefined) {
loge(`Cannot find context for context id:${contextId}`);
return;
}
if (context.entity === undefined) {
loge(`Cannot find holder for context id:${contextId}`);
return;
}
if (Reflect.has(context.entity, methodName)) {
const argumentsList = [];
for (let i = 2; i < arguments.length; i++) {
argumentsList.push(arguments[i]);
}
return Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList);
}
else {
loge(`Cannot find method for context id:${contextId},method name is:${methodName}`);
}
}
function jsObtainEntry(contextId) { function jsObtainEntry(contextId) {
const context = jsObtainContext(contextId); const context = jsObtainContext(contextId);
const exportFunc = (constructor) => { const exportFunc = (constructor) => {
@ -1567,6 +1588,7 @@ var doric = /*#__PURE__*/Object.freeze({
__require__: __require__, __require__: __require__,
jsRegisterModule: jsRegisterModule, jsRegisterModule: jsRegisterModule,
jsCallEntityMethod: jsCallEntityMethod, jsCallEntityMethod: jsCallEntityMethod,
pureCallEntityMethod: pureCallEntityMethod,
jsObtainEntry: jsObtainEntry, jsObtainEntry: jsObtainEntry,
jsCallbackTimer: jsCallbackTimer jsCallbackTimer: jsCallbackTimer
}); });
@ -3030,7 +3052,6 @@ class List extends Superview {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.cachedViews = new Map; this.cachedViews = new Map;
this.ignoreDirtyCallOnce = false;
this.itemCount = 0; this.itemCount = 0;
this.batchCount = 15; this.batchCount = 15;
} }
@ -3056,16 +3077,7 @@ class List extends Superview {
this.cachedViews.set(`${itemIdx}`, view); this.cachedViews.set(`${itemIdx}`, view);
return view; return view;
} }
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return super.isDirty();
}
renderBunchedItems(start, length) { renderBunchedItems(start, length) {
this.ignoreDirtyCallOnce = true;
return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map((_, idx) => { return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map((_, idx) => {
const listItem = this.getItem(start + idx); const listItem = this.getItem(start + idx);
return listItem.toModel(); return listItem.toModel();
@ -3159,7 +3171,6 @@ class Slider extends Superview {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.cachedViews = new Map; this.cachedViews = new Map;
this.ignoreDirtyCallOnce = false;
this.itemCount = 0; this.itemCount = 0;
this.batchCount = 3; this.batchCount = 3;
} }
@ -3172,16 +3183,7 @@ class Slider extends Superview {
this.cachedViews.set(`${itemIdx}`, view); this.cachedViews.set(`${itemIdx}`, view);
return view; return view;
} }
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return super.isDirty();
}
renderBunchedItems(start, length) { renderBunchedItems(start, length) {
this.ignoreDirtyCallOnce = true;
return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => { return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => {
const slideItem = this.getItem(start + idx); const slideItem = this.getItem(start + idx);
return slideItem.toModel(); return slideItem.toModel();
@ -3447,7 +3449,6 @@ class FlowLayout extends Superview {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.cachedViews = new Map; this.cachedViews = new Map;
this.ignoreDirtyCallOnce = false;
this.columnCount = 2; this.columnCount = 2;
this.itemCount = 0; this.itemCount = 0;
this.batchCount = 15; this.batchCount = 15;
@ -3470,16 +3471,7 @@ class FlowLayout extends Superview {
this.cachedViews.set(`${itemIdx}`, view); this.cachedViews.set(`${itemIdx}`, view);
return view; return view;
} }
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return super.isDirty();
}
renderBunchedItems(start, length) { renderBunchedItems(start, length) {
this.ignoreDirtyCallOnce = true;
return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => { return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => {
const listItem = this.getItem(start + idx); const listItem = this.getItem(start + idx);
return listItem.toModel(); return listItem.toModel();

3
doric-js/index.d.ts vendored
View File

@ -607,7 +607,6 @@ declare module 'doric/lib/src/widget/list' {
animated?: boolean; animated?: boolean;
}): Promise<any>; }): Promise<any>;
reset(): void; reset(): void;
isDirty(): boolean;
toModel(): NativeViewModel; toModel(): NativeViewModel;
} }
export function list(config: Partial<List>): List; export function list(config: Partial<List>): List;
@ -631,7 +630,6 @@ declare module 'doric/lib/src/widget/slider' {
batchCount: number; batchCount: number;
onPageSlided?: (index: number) => void; onPageSlided?: (index: number) => void;
loop?: boolean; loop?: boolean;
isDirty(): boolean;
slidePage(context: BridgeContext, page: number, smooth?: boolean): Promise<any>; slidePage(context: BridgeContext, page: number, smooth?: boolean): Promise<any>;
getSlidedPage(context: BridgeContext): Promise<number>; getSlidedPage(context: BridgeContext): Promise<number>;
} }
@ -722,7 +720,6 @@ declare module 'doric/lib/src/widget/flowlayout' {
y: number; y: number;
}) => void; }) => void;
reset(): void; reset(): void;
isDirty(): boolean;
toModel(): NativeViewModel; toModel(): NativeViewModel;
} }
export function flowlayout(config: Partial<FlowLayout>): FlowLayout; export function flowlayout(config: Partial<FlowLayout>): FlowLayout;

View File

@ -23,6 +23,7 @@ export declare function jsReleaseContext(id: string): void;
export declare function __require__(name: string): any; export declare function __require__(name: string): any;
export declare function jsRegisterModule(name: string, moduleObject: any): void; export declare function jsRegisterModule(name: string, moduleObject: any): void;
export declare function jsCallEntityMethod(contextId: string, methodName: string, args?: any): any; export declare function jsCallEntityMethod(contextId: string, methodName: string, args?: any): any;
export declare function pureCallEntityMethod(contextId: string, methodName: string, args?: any): any;
declare type ClassType<T> = new (...args: any) => T; declare type ClassType<T> = new (...args: any) => T;
export declare function jsObtainEntry(contextId: string): () => ClassType<object> | ((constructor: ClassType<object>) => ClassType<object>); export declare function jsObtainEntry(contextId: string): () => ClassType<object> | ((constructor: ClassType<object>) => ClassType<object>);
export declare function jsCallbackTimer(timerId: number): void; export declare function jsCallbackTimer(timerId: number): void;

View File

@ -215,6 +215,27 @@ export function jsCallEntityMethod(contextId, methodName, args) {
loge(`Cannot find method for context id:${contextId},method name is:${methodName}`); loge(`Cannot find method for context id:${contextId},method name is:${methodName}`);
} }
} }
export function pureCallEntityMethod(contextId, methodName, args) {
const context = gContexts.get(contextId);
if (context === undefined) {
loge(`Cannot find context for context id:${contextId}`);
return;
}
if (context.entity === undefined) {
loge(`Cannot find holder for context id:${contextId}`);
return;
}
if (Reflect.has(context.entity, methodName)) {
const argumentsList = [];
for (let i = 2; i < arguments.length; i++) {
argumentsList.push(arguments[i]);
}
return Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList);
}
else {
loge(`Cannot find method for context id:${contextId},method name is:${methodName}`);
}
}
export function jsObtainEntry(contextId) { export function jsObtainEntry(contextId) {
const context = jsObtainContext(contextId); const context = jsObtainContext(contextId);
const exportFunc = (constructor) => { const exportFunc = (constructor) => {

View File

@ -8,7 +8,6 @@ export declare class FlowLayoutItem extends Stack {
} }
export declare class FlowLayout extends Superview { export declare class FlowLayout extends Superview {
private cachedViews; private cachedViews;
private ignoreDirtyCallOnce;
allSubviews(): IterableIterator<FlowLayoutItem> | FlowLayoutItem[]; allSubviews(): IterableIterator<FlowLayoutItem> | FlowLayoutItem[];
columnCount: number; columnCount: number;
columnSpace?: number; columnSpace?: number;
@ -29,7 +28,6 @@ export declare class FlowLayout extends Superview {
}) => void; }) => void;
reset(): void; reset(): void;
private getItem; private getItem;
isDirty(): boolean;
private renderBunchedItems; private renderBunchedItems;
toModel(): NativeViewModel; toModel(): NativeViewModel;
} }

View File

@ -35,7 +35,6 @@ export class FlowLayout extends Superview {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.cachedViews = new Map; this.cachedViews = new Map;
this.ignoreDirtyCallOnce = false;
this.columnCount = 2; this.columnCount = 2;
this.itemCount = 0; this.itemCount = 0;
this.batchCount = 15; this.batchCount = 15;
@ -58,16 +57,7 @@ export class FlowLayout extends Superview {
this.cachedViews.set(`${itemIdx}`, view); this.cachedViews.set(`${itemIdx}`, view);
return view; return view;
} }
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return super.isDirty();
}
renderBunchedItems(start, length) { renderBunchedItems(start, length) {
this.ignoreDirtyCallOnce = true;
return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => { return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => {
const listItem = this.getItem(start + idx); const listItem = this.getItem(start + idx);
return listItem.toModel(); return listItem.toModel();

View File

@ -9,7 +9,6 @@ export declare class ListItem extends Stack {
} }
export declare class List extends Superview { export declare class List extends Superview {
private cachedViews; private cachedViews;
private ignoreDirtyCallOnce;
allSubviews(): IterableIterator<ListItem> | ListItem[]; allSubviews(): IterableIterator<ListItem> | ListItem[];
itemCount: number; itemCount: number;
renderItem: (index: number) => ListItem; renderItem: (index: number) => ListItem;
@ -31,7 +30,6 @@ export declare class List extends Superview {
}): Promise<any>; }): Promise<any>;
reset(): void; reset(): void;
private getItem; private getItem;
isDirty(): boolean;
private renderBunchedItems; private renderBunchedItems;
toModel(): NativeViewModel; toModel(): NativeViewModel;
} }

View File

@ -35,7 +35,6 @@ export class List extends Superview {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.cachedViews = new Map; this.cachedViews = new Map;
this.ignoreDirtyCallOnce = false;
this.itemCount = 0; this.itemCount = 0;
this.batchCount = 15; this.batchCount = 15;
} }
@ -61,16 +60,7 @@ export class List extends Superview {
this.cachedViews.set(`${itemIdx}`, view); this.cachedViews.set(`${itemIdx}`, view);
return view; return view;
} }
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return super.isDirty();
}
renderBunchedItems(start, length) { renderBunchedItems(start, length) {
this.ignoreDirtyCallOnce = true;
return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map((_, idx) => { return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map((_, idx) => {
const listItem = this.getItem(start + idx); const listItem = this.getItem(start + idx);
return listItem.toModel(); return listItem.toModel();

View File

@ -9,7 +9,6 @@ export declare class SlideItem extends Stack {
} }
export declare class Slider extends Superview { export declare class Slider extends Superview {
private cachedViews; private cachedViews;
private ignoreDirtyCallOnce;
allSubviews(): IterableIterator<SlideItem>; allSubviews(): IterableIterator<SlideItem>;
itemCount: number; itemCount: number;
renderPage: (index: number) => SlideItem; renderPage: (index: number) => SlideItem;
@ -17,7 +16,6 @@ export declare class Slider extends Superview {
onPageSlided?: (index: number) => void; onPageSlided?: (index: number) => void;
loop?: boolean; loop?: boolean;
private getItem; private getItem;
isDirty(): boolean;
private renderBunchedItems; private renderBunchedItems;
slidePage(context: BridgeContext, page: number, smooth?: boolean): Promise<any>; slidePage(context: BridgeContext, page: number, smooth?: boolean): Promise<any>;
getSlidedPage(context: BridgeContext): Promise<number>; getSlidedPage(context: BridgeContext): Promise<number>;

View File

@ -35,7 +35,6 @@ export class Slider extends Superview {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.cachedViews = new Map; this.cachedViews = new Map;
this.ignoreDirtyCallOnce = false;
this.itemCount = 0; this.itemCount = 0;
this.batchCount = 3; this.batchCount = 3;
} }
@ -48,16 +47,7 @@ export class Slider extends Superview {
this.cachedViews.set(`${itemIdx}`, view); this.cachedViews.set(`${itemIdx}`, view);
return view; return view;
} }
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return super.isDirty();
}
renderBunchedItems(start, length) { renderBunchedItems(start, length) {
this.ignoreDirtyCallOnce = true;
return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => { return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => {
const slideItem = this.getItem(start + idx); const slideItem = this.getItem(start + idx);
return slideItem.toModel(); return slideItem.toModel();

View File

@ -238,6 +238,26 @@ export function jsCallEntityMethod(contextId: string, methodName: string, args?:
} }
} }
export function pureCallEntityMethod(contextId: string, methodName: string, args?: any) {
const context = gContexts.get(contextId)
if (context === undefined) {
loge(`Cannot find context for context id:${contextId}`)
return
}
if (context.entity === undefined) {
loge(`Cannot find holder for context id:${contextId}`)
return
}
if (Reflect.has(context.entity, methodName)) {
const argumentsList: any = []
for (let i = 2; i < arguments.length; i++) {
argumentsList.push(arguments[i])
}
return Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList)
} else {
loge(`Cannot find method for context id:${contextId},method name is:${methodName}`)
}
}
type ClassType<T> = new (...args: any) => T type ClassType<T> = new (...args: any) => T
export function jsObtainEntry(contextId: string) { export function jsObtainEntry(contextId: string) {

View File

@ -276,6 +276,27 @@ export function jsCallEntityMethod(contextId: string, methodName: string, args?:
} }
} }
export function pureCallEntityMethod(contextId: string, methodName: string, args?: any) {
const context = gContexts.get(contextId)
if (context === undefined) {
loge(`Cannot find context for context id:${contextId}`)
return
}
if (context.entity === undefined) {
loge(`Cannot find holder for context id:${contextId}`)
return
}
if (Reflect.has(context.entity, methodName)) {
const argumentsList: any = []
for (let i = 2; i < arguments.length; i++) {
argumentsList.push(arguments[i])
}
return Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList)
} else {
loge(`Cannot find method for context id:${contextId},method name is:${methodName}`)
}
}
type ClassType<T> = new (...args: any) => T type ClassType<T> = new (...args: any) => T
export function jsObtainEntry(contextId: string) { export function jsObtainEntry(contextId: string) {

View File

@ -27,7 +27,6 @@ export class FlowLayoutItem extends Stack {
export class FlowLayout extends Superview { export class FlowLayout extends Superview {
private cachedViews: Map<string, FlowLayoutItem> = new Map private cachedViews: Map<string, FlowLayoutItem> = new Map
private ignoreDirtyCallOnce = false
allSubviews() { allSubviews() {
if (this.loadMoreView) { if (this.loadMoreView) {
@ -80,18 +79,7 @@ export class FlowLayout extends Superview {
this.cachedViews.set(`${itemIdx}`, view) this.cachedViews.set(`${itemIdx}`, view)
return view return view
} }
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false
//Ignore the dirty call once.
return false
}
return super.isDirty()
}
private renderBunchedItems(start: number, length: number) { private renderBunchedItems(start: number, length: number) {
this.ignoreDirtyCallOnce = true;
return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => { return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => {
const listItem = this.getItem(start + idx) const listItem = this.getItem(start + idx)
return listItem.toModel() return listItem.toModel()

View File

@ -30,7 +30,6 @@ export class ListItem extends Stack {
export class List extends Superview { export class List extends Superview {
private cachedViews: Map<string, ListItem> = new Map private cachedViews: Map<string, ListItem> = new Map
private ignoreDirtyCallOnce = false
allSubviews() { allSubviews() {
if (this.loadMoreView) { if (this.loadMoreView) {
@ -83,17 +82,7 @@ export class List extends Superview {
return view return view
} }
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false
//Ignore the dirty call once.
return false
}
return super.isDirty()
}
private renderBunchedItems(start: number, length: number) { private renderBunchedItems(start: number, length: number) {
this.ignoreDirtyCallOnce = true
return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map((_, idx) => { return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map((_, idx) => {
const listItem = this.getItem(start + idx) const listItem = this.getItem(start + idx)
return listItem.toModel() return listItem.toModel()

View File

@ -31,8 +31,6 @@ export class SlideItem extends Stack {
export class Slider extends Superview { export class Slider extends Superview {
private cachedViews: Map<string, SlideItem> = new Map private cachedViews: Map<string, SlideItem> = new Map
private ignoreDirtyCallOnce = false
allSubviews() { allSubviews() {
return this.cachedViews.values() return this.cachedViews.values()
} }
@ -58,17 +56,7 @@ export class Slider extends Superview {
return view return view
} }
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false
//Ignore the dirty call once.
return false
}
return super.isDirty()
}
private renderBunchedItems(start: number, length: number) { private renderBunchedItems(start: number, length: number) {
this.ignoreDirtyCallOnce = true;
return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => { return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => {
const slideItem = this.getItem(start + idx) const slideItem = this.getItem(start + idx)
return slideItem.toModel() return slideItem.toModel()

View File

@ -1399,6 +1399,27 @@ var doric = (function (exports) {
loge(`Cannot find method for context id:${contextId},method name is:${methodName}`); loge(`Cannot find method for context id:${contextId},method name is:${methodName}`);
} }
} }
function pureCallEntityMethod(contextId, methodName, args) {
const context = gContexts.get(contextId);
if (context === undefined) {
loge(`Cannot find context for context id:${contextId}`);
return;
}
if (context.entity === undefined) {
loge(`Cannot find holder for context id:${contextId}`);
return;
}
if (Reflect.has(context.entity, methodName)) {
const argumentsList = [];
for (let i = 2; i < arguments.length; i++) {
argumentsList.push(arguments[i]);
}
return Reflect.apply(Reflect.get(context.entity, methodName), context.entity, argumentsList);
}
else {
loge(`Cannot find method for context id:${contextId},method name is:${methodName}`);
}
}
function jsObtainEntry(contextId) { function jsObtainEntry(contextId) {
const context = jsObtainContext(contextId); const context = jsObtainContext(contextId);
const exportFunc = (constructor) => { const exportFunc = (constructor) => {
@ -1540,6 +1561,7 @@ var doric = (function (exports) {
exports.jsObtainEntry = jsObtainEntry; exports.jsObtainEntry = jsObtainEntry;
exports.jsRegisterModule = jsRegisterModule; exports.jsRegisterModule = jsRegisterModule;
exports.jsReleaseContext = jsReleaseContext; exports.jsReleaseContext = jsReleaseContext;
exports.pureCallEntityMethod = pureCallEntityMethod;
Object.defineProperty(exports, '__esModule', { value: true }); Object.defineProperty(exports, '__esModule', { value: true });
@ -3084,7 +3106,6 @@ class List extends Superview {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.cachedViews = new Map; this.cachedViews = new Map;
this.ignoreDirtyCallOnce = false;
this.itemCount = 0; this.itemCount = 0;
this.batchCount = 15; this.batchCount = 15;
} }
@ -3110,16 +3131,7 @@ class List extends Superview {
this.cachedViews.set(`${itemIdx}`, view); this.cachedViews.set(`${itemIdx}`, view);
return view; return view;
} }
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return super.isDirty();
}
renderBunchedItems(start, length) { renderBunchedItems(start, length) {
this.ignoreDirtyCallOnce = true;
return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map((_, idx) => { return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map((_, idx) => {
const listItem = this.getItem(start + idx); const listItem = this.getItem(start + idx);
return listItem.toModel(); return listItem.toModel();
@ -3213,7 +3225,6 @@ class Slider extends Superview {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.cachedViews = new Map; this.cachedViews = new Map;
this.ignoreDirtyCallOnce = false;
this.itemCount = 0; this.itemCount = 0;
this.batchCount = 3; this.batchCount = 3;
} }
@ -3226,16 +3237,7 @@ class Slider extends Superview {
this.cachedViews.set(`${itemIdx}`, view); this.cachedViews.set(`${itemIdx}`, view);
return view; return view;
} }
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return super.isDirty();
}
renderBunchedItems(start, length) { renderBunchedItems(start, length) {
this.ignoreDirtyCallOnce = true;
return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => { return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => {
const slideItem = this.getItem(start + idx); const slideItem = this.getItem(start + idx);
return slideItem.toModel(); return slideItem.toModel();
@ -3501,7 +3503,6 @@ class FlowLayout extends Superview {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.cachedViews = new Map; this.cachedViews = new Map;
this.ignoreDirtyCallOnce = false;
this.columnCount = 2; this.columnCount = 2;
this.itemCount = 0; this.itemCount = 0;
this.batchCount = 15; this.batchCount = 15;
@ -3524,16 +3525,7 @@ class FlowLayout extends Superview {
this.cachedViews.set(`${itemIdx}`, view); this.cachedViews.set(`${itemIdx}`, view);
return view; return view;
} }
isDirty() {
if (this.ignoreDirtyCallOnce) {
this.ignoreDirtyCallOnce = false;
//Ignore the dirty call once.
return false;
}
return super.isDirty();
}
renderBunchedItems(start, length) { renderBunchedItems(start, length) {
this.ignoreDirtyCallOnce = true;
return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => { return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => {
const listItem = this.getItem(start + idx); const listItem = this.getItem(start + idx);
return listItem.toModel(); return listItem.toModel();
@ -4723,6 +4715,13 @@ var doric_web = (function (exports, axios, sandbox) {
} }
return Reflect.apply(this.context.invokeEntityMethod, this.context, argumentsList); return Reflect.apply(this.context.invokeEntityMethod, this.context, argumentsList);
} }
pureCallJSResponse(funcId, ...args) {
const argumentsList = ['__response__', this.getIdList(), funcId];
for (let i = 1; i < arguments.length; i++) {
argumentsList.push(arguments[i]);
}
return Reflect.apply(this.context.pureInvokeEntityMethod, this.context, argumentsList);
}
} }
class DoricSuperNode extends DoricViewNode { class DoricSuperNode extends DoricViewNode {
constructor() { constructor() {
@ -5507,7 +5506,7 @@ var doric_web = (function (exports, axios, sandbox) {
onBlended() { onBlended() {
super.onBlended(); super.onBlended();
if (this.childNodes.length !== this.itemCount) { if (this.childNodes.length !== this.itemCount) {
const ret = this.callJSResponse("renderBunchedItems", this.childNodes.length, this.itemCount); const ret = this.pureCallJSResponse("renderBunchedItems", this.childNodes.length, this.itemCount);
this.childNodes = this.childNodes.concat(ret.map(e => { this.childNodes = this.childNodes.concat(ret.map(e => {
const viewNode = DoricViewNode.create(this.context, e.type); const viewNode = DoricViewNode.create(this.context, e.type);
viewNode.viewId = e.id; viewNode.viewId = e.id;
@ -5533,6 +5532,9 @@ var doric_web = (function (exports, axios, sandbox) {
if (this.loadMoreViewNode) { if (this.loadMoreViewNode) {
this.view.appendChild(this.loadMoreViewNode.view); this.view.appendChild(this.loadMoreViewNode.view);
} }
if (this.view.scrollTop + this.view.offsetHeight === this.view.scrollHeight) {
this.onScrollToEnd();
}
} }
} }
blendSubNode(model) { blendSubNode(model) {
@ -5828,6 +5830,13 @@ ${content}
} }
return Reflect.apply(sandbox.jsCallEntityMethod, this.panel, argumentsList); return Reflect.apply(sandbox.jsCallEntityMethod, this.panel, argumentsList);
} }
pureInvokeEntityMethod(method, ...otherArgs) {
const argumentsList = [this.contextId];
for (let i = 0; i < arguments.length; i++) {
argumentsList.push(arguments[i]);
}
return Reflect.apply(sandbox.pureCallEntityMethod, this.panel, argumentsList);
}
init(data) { init(data) {
this.invokeEntityMethod("__init__", data); this.invokeEntityMethod("__init__", data);
} }

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
import { jsObtainContext, jsCallEntityMethod } from 'doric/src/runtime/sandbox' import { jsObtainContext, jsCallEntityMethod, pureCallEntityMethod } from 'doric/src/runtime/sandbox'
import { Panel } from 'doric' import { Panel } from 'doric'
import { DoricPlugin } from "./DoricPlugin" import { DoricPlugin } from "./DoricPlugin"
import { createContext, destroyContext } from "./DoricDriver" import { createContext, destroyContext } from "./DoricDriver"
@ -39,6 +39,14 @@ export class DoricContext {
return Reflect.apply(jsCallEntityMethod, this.panel, argumentsList) return Reflect.apply(jsCallEntityMethod, this.panel, argumentsList)
} }
pureInvokeEntityMethod(method: string, ...otherArgs: any) {
const argumentsList: any = [this.contextId]
for (let i = 0; i < arguments.length; i++) {
argumentsList.push(arguments[i])
}
return Reflect.apply(pureCallEntityMethod, this.panel, argumentsList)
}
init(data?: string) { init(data?: string) {
this.invokeEntityMethod("__init__", data) this.invokeEntityMethod("__init__", data)
} }

View File

@ -46,7 +46,7 @@ export class DoricListNode extends DoricSuperNode {
onBlended() { onBlended() {
super.onBlended() super.onBlended()
if (this.childNodes.length !== this.itemCount) { if (this.childNodes.length !== this.itemCount) {
const ret = this.callJSResponse("renderBunchedItems", this.childNodes.length, this.itemCount) as DVModel[] const ret = this.pureCallJSResponse("renderBunchedItems", this.childNodes.length, this.itemCount) as DVModel[]
this.childNodes = this.childNodes.concat(ret.map(e => { this.childNodes = this.childNodes.concat(ret.map(e => {
const viewNode = DoricViewNode.create(this.context, e.type) as DoricListItemNode const viewNode = DoricViewNode.create(this.context, e.type) as DoricListItemNode
viewNode.viewId = e.id viewNode.viewId = e.id
@ -72,6 +72,9 @@ export class DoricListNode extends DoricSuperNode {
if (this.loadMoreViewNode) { if (this.loadMoreViewNode) {
this.view.appendChild(this.loadMoreViewNode.view) this.view.appendChild(this.loadMoreViewNode.view)
} }
if (this.view.scrollTop + this.view.offsetHeight === this.view.scrollHeight) {
this.onScrollToEnd()
}
} }
} }
blendSubNode(model: DVModel) { blendSubNode(model: DVModel) {

View File

@ -311,6 +311,14 @@ export abstract class DoricViewNode {
} }
return Reflect.apply(this.context.invokeEntityMethod, this.context, argumentsList) return Reflect.apply(this.context.invokeEntityMethod, this.context, argumentsList)
} }
pureCallJSResponse(funcId: string, ...args: any) {
const argumentsList: any = ['__response__', this.getIdList(), funcId]
for (let i = 1; i < arguments.length; i++) {
argumentsList.push(arguments[i])
}
return Reflect.apply(this.context.pureInvokeEntityMethod, this.context, argumentsList)
}
} }