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

@@ -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 { DoricPlugin } from "./DoricPlugin"
import { createContext, destroyContext } from "./DoricDriver"
@@ -39,6 +39,14 @@ export class DoricContext {
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) {
this.invokeEntityMethod("__init__", data)
}

View File

@@ -46,7 +46,7 @@ export class DoricListNode extends DoricSuperNode {
onBlended() {
super.onBlended()
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 => {
const viewNode = DoricViewNode.create(this.context, e.type) as DoricListItemNode
viewNode.viewId = e.id
@@ -72,6 +72,9 @@ export class DoricListNode extends DoricSuperNode {
if (this.loadMoreViewNode) {
this.view.appendChild(this.loadMoreViewNode.view)
}
if (this.view.scrollTop + this.view.offsetHeight === this.view.scrollHeight) {
this.onScrollToEnd()
}
}
}
blendSubNode(model: DVModel) {

View File

@@ -311,6 +311,14 @@ export abstract class DoricViewNode {
}
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)
}
}