feat:add pureCallEntityMethod,avoid hook affects
This commit is contained in:
1
doric-js/lib/src/runtime/sandbox.d.ts
vendored
1
doric-js/lib/src/runtime/sandbox.d.ts
vendored
@@ -23,6 +23,7 @@ export declare function jsReleaseContext(id: string): void;
|
||||
export declare function __require__(name: string): any;
|
||||
export declare function jsRegisterModule(name: string, moduleObject: any): void;
|
||||
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;
|
||||
export declare function jsObtainEntry(contextId: string): () => ClassType<object> | ((constructor: ClassType<object>) => ClassType<object>);
|
||||
export declare function jsCallbackTimer(timerId: number): void;
|
||||
|
@@ -215,6 +215,27 @@ export function jsCallEntityMethod(contextId, methodName, args) {
|
||||
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) {
|
||||
const context = jsObtainContext(contextId);
|
||||
const exportFunc = (constructor) => {
|
||||
|
2
doric-js/lib/src/widget/flowlayout.d.ts
vendored
2
doric-js/lib/src/widget/flowlayout.d.ts
vendored
@@ -8,7 +8,6 @@ export declare class FlowLayoutItem extends Stack {
|
||||
}
|
||||
export declare class FlowLayout extends Superview {
|
||||
private cachedViews;
|
||||
private ignoreDirtyCallOnce;
|
||||
allSubviews(): IterableIterator<FlowLayoutItem> | FlowLayoutItem[];
|
||||
columnCount: number;
|
||||
columnSpace?: number;
|
||||
@@ -29,7 +28,6 @@ export declare class FlowLayout extends Superview {
|
||||
}) => void;
|
||||
reset(): void;
|
||||
private getItem;
|
||||
isDirty(): boolean;
|
||||
private renderBunchedItems;
|
||||
toModel(): NativeViewModel;
|
||||
}
|
||||
|
@@ -35,7 +35,6 @@ export class FlowLayout extends Superview {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.cachedViews = new Map;
|
||||
this.ignoreDirtyCallOnce = false;
|
||||
this.columnCount = 2;
|
||||
this.itemCount = 0;
|
||||
this.batchCount = 15;
|
||||
@@ -58,16 +57,7 @@ export class FlowLayout extends Superview {
|
||||
this.cachedViews.set(`${itemIdx}`, view);
|
||||
return view;
|
||||
}
|
||||
isDirty() {
|
||||
if (this.ignoreDirtyCallOnce) {
|
||||
this.ignoreDirtyCallOnce = false;
|
||||
//Ignore the dirty call once.
|
||||
return false;
|
||||
}
|
||||
return super.isDirty();
|
||||
}
|
||||
renderBunchedItems(start, length) {
|
||||
this.ignoreDirtyCallOnce = true;
|
||||
return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => {
|
||||
const listItem = this.getItem(start + idx);
|
||||
return listItem.toModel();
|
||||
|
2
doric-js/lib/src/widget/list.d.ts
vendored
2
doric-js/lib/src/widget/list.d.ts
vendored
@@ -9,7 +9,6 @@ export declare class ListItem extends Stack {
|
||||
}
|
||||
export declare class List extends Superview {
|
||||
private cachedViews;
|
||||
private ignoreDirtyCallOnce;
|
||||
allSubviews(): IterableIterator<ListItem> | ListItem[];
|
||||
itemCount: number;
|
||||
renderItem: (index: number) => ListItem;
|
||||
@@ -31,7 +30,6 @@ export declare class List extends Superview {
|
||||
}): Promise<any>;
|
||||
reset(): void;
|
||||
private getItem;
|
||||
isDirty(): boolean;
|
||||
private renderBunchedItems;
|
||||
toModel(): NativeViewModel;
|
||||
}
|
||||
|
@@ -35,7 +35,6 @@ export class List extends Superview {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.cachedViews = new Map;
|
||||
this.ignoreDirtyCallOnce = false;
|
||||
this.itemCount = 0;
|
||||
this.batchCount = 15;
|
||||
}
|
||||
@@ -61,16 +60,7 @@ export class List extends Superview {
|
||||
this.cachedViews.set(`${itemIdx}`, view);
|
||||
return view;
|
||||
}
|
||||
isDirty() {
|
||||
if (this.ignoreDirtyCallOnce) {
|
||||
this.ignoreDirtyCallOnce = false;
|
||||
//Ignore the dirty call once.
|
||||
return false;
|
||||
}
|
||||
return super.isDirty();
|
||||
}
|
||||
renderBunchedItems(start, length) {
|
||||
this.ignoreDirtyCallOnce = true;
|
||||
return new Array(Math.max(0, Math.min(length, this.itemCount - start))).fill(0).map((_, idx) => {
|
||||
const listItem = this.getItem(start + idx);
|
||||
return listItem.toModel();
|
||||
|
2
doric-js/lib/src/widget/slider.d.ts
vendored
2
doric-js/lib/src/widget/slider.d.ts
vendored
@@ -9,7 +9,6 @@ export declare class SlideItem extends Stack {
|
||||
}
|
||||
export declare class Slider extends Superview {
|
||||
private cachedViews;
|
||||
private ignoreDirtyCallOnce;
|
||||
allSubviews(): IterableIterator<SlideItem>;
|
||||
itemCount: number;
|
||||
renderPage: (index: number) => SlideItem;
|
||||
@@ -17,7 +16,6 @@ export declare class Slider extends Superview {
|
||||
onPageSlided?: (index: number) => void;
|
||||
loop?: boolean;
|
||||
private getItem;
|
||||
isDirty(): boolean;
|
||||
private renderBunchedItems;
|
||||
slidePage(context: BridgeContext, page: number, smooth?: boolean): Promise<any>;
|
||||
getSlidedPage(context: BridgeContext): Promise<number>;
|
||||
|
@@ -35,7 +35,6 @@ export class Slider extends Superview {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.cachedViews = new Map;
|
||||
this.ignoreDirtyCallOnce = false;
|
||||
this.itemCount = 0;
|
||||
this.batchCount = 3;
|
||||
}
|
||||
@@ -48,16 +47,7 @@ export class Slider extends Superview {
|
||||
this.cachedViews.set(`${itemIdx}`, view);
|
||||
return view;
|
||||
}
|
||||
isDirty() {
|
||||
if (this.ignoreDirtyCallOnce) {
|
||||
this.ignoreDirtyCallOnce = false;
|
||||
//Ignore the dirty call once.
|
||||
return false;
|
||||
}
|
||||
return super.isDirty();
|
||||
}
|
||||
renderBunchedItems(start, length) {
|
||||
this.ignoreDirtyCallOnce = true;
|
||||
return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => {
|
||||
const slideItem = this.getItem(start + idx);
|
||||
return slideItem.toModel();
|
||||
|
Reference in New Issue
Block a user