diff --git a/doric-js/bundle/doric-lib.js b/doric-js/bundle/doric-lib.js index 4de47dee..3fcadcd7 100644 --- a/doric-js/bundle/doric-lib.js +++ b/doric-js/bundle/doric-lib.js @@ -736,40 +736,23 @@ class Panel { this.context.shader.render(model); } hookBeforeNativeCall() { - this.__root__.clean(); - for (let v of this.headviews.values()) { - v.clean(); - } } hookAfterNativeCall() { //Here insert a native call to ensure the promise is resolved done. - if (Environment.platform === 'h5') { - setTimeout(() => { - if (this.__root__.isDirty()) { - const model = this.__root__.toModel(); - this.nativeRender(model); - } - for (let v of this.headviews.values()) { - if (v.isDirty()) { - const model = v.toModel(); - this.nativeRender(model); - } - } - }, 0); - } - else { - nativeEmpty(); + Promise.resolve().then(() => { if (this.__root__.isDirty()) { const model = this.__root__.toModel(); this.nativeRender(model); + this.__root__.clean(); } for (let v of this.headviews.values()) { if (v.isDirty()) { const model = v.toModel(); this.nativeRender(model); + v.clean(); } } - } + }); } } __decorate$2([ diff --git a/doric-js/bundle/doric-vm.js b/doric-js/bundle/doric-vm.js index ecb1a13d..d45430d3 100644 --- a/doric-js/bundle/doric-vm.js +++ b/doric-js/bundle/doric-vm.js @@ -2184,40 +2184,23 @@ class Panel { this.context.shader.render(model); } hookBeforeNativeCall() { - this.__root__.clean(); - for (let v of this.headviews.values()) { - v.clean(); - } } hookAfterNativeCall() { //Here insert a native call to ensure the promise is resolved done. - if (Environment.platform === 'h5') { - setTimeout(() => { - if (this.__root__.isDirty()) { - const model = this.__root__.toModel(); - this.nativeRender(model); - } - for (let v of this.headviews.values()) { - if (v.isDirty()) { - const model = v.toModel(); - this.nativeRender(model); - } - } - }, 0); - } - else { - nativeEmpty(); + Promise.resolve().then(() => { if (this.__root__.isDirty()) { const model = this.__root__.toModel(); this.nativeRender(model); + this.__root__.clean(); } for (let v of this.headviews.values()) { if (v.isDirty()) { const model = v.toModel(); this.nativeRender(model); + v.clean(); } } - } + }); } } __decorate$2([ diff --git a/doric-js/src/ui/panel.ts b/doric-js/src/ui/panel.ts index 46a93041..4dfa3176 100644 --- a/doric-js/src/ui/panel.ts +++ b/doric-js/src/ui/panel.ts @@ -20,7 +20,6 @@ import { Model } from '../util/types' import { Root } from '../widget/layouts' import { BridgeContext } from '../runtime/global' - export function NativeCall(target: Panel, propertyKey: string, descriptor: PropertyDescriptor) { const originVal = descriptor.value descriptor.value = function () { @@ -32,8 +31,6 @@ export function NativeCall(target: Panel, propertyKey: string, descriptor: Prope type Frame = { width: number, height: number } -declare function nativeEmpty(): void - export abstract class Panel { context!: BridgeContext onCreate() { } @@ -144,40 +141,24 @@ export abstract class Panel { } private hookBeforeNativeCall() { - this.__root__.clean() - for (let v of this.headviews.values()) { - v.clean() - } } private hookAfterNativeCall() { //Here insert a native call to ensure the promise is resolved done. - if (Environment.platform === 'h5') { - setTimeout(() => { - if (this.__root__.isDirty()) { - const model = this.__root__.toModel() - this.nativeRender(model) - } - for (let v of this.headviews.values()) { - if (v.isDirty()) { - const model = v.toModel() - this.nativeRender(model) - } - } - }, 0) - } else { - nativeEmpty() + Promise.resolve().then(() => { if (this.__root__.isDirty()) { const model = this.__root__.toModel() this.nativeRender(model) + this.__root__.clean() } for (let v of this.headviews.values()) { if (v.isDirty()) { const model = v.toModel() this.nativeRender(model) + v.clean() } } - } + }) } } \ No newline at end of file