feat:Check dirty use Promise to scheme it to micro queue

This commit is contained in:
pengfei.zhou
2019-12-25 15:13:36 +08:00
committed by osborn
parent 4b1fcc439d
commit 665d11f8be
3 changed files with 12 additions and 65 deletions

View File

@@ -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([

View File

@@ -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([