feat:fix when call build and onShow at once,then onRenderFinishedCallback maybe called before the render action finished

This commit is contained in:
pengfei.zhou
2020-04-27 15:08:18 +08:00
committed by osborn
parent cabb1b1f82
commit c34fe50104
8 changed files with 80 additions and 19 deletions

View File

@@ -13,6 +13,7 @@ export declare abstract class Panel {
private __root__;
private headviews;
private onRenderFinishedCallback;
private __rendering__;
addHeadView(type: string, v: View): void;
allHeadViews(): IterableIterator<Map<string, View>>;
removeHeadView(type: string, v: View | string): void;

View File

@@ -38,6 +38,7 @@ export class Panel {
this.__root__ = new Root;
this.headviews = new Map;
this.onRenderFinishedCallback = [];
this.__rendering__ = false;
}
onCreate() { }
onDestroy() { }
@@ -187,9 +188,18 @@ export class Panel {
}
});
}
Promise.all(promises).then(_ => {
this.onRenderFinished();
});
if (this.__rendering__) {
//skip
Promise.all(promises).then(_ => {
});
}
else {
this.__rendering__ = true;
Promise.all(promises).then(_ => {
this.__rendering__ = false;
this.onRenderFinished();
});
}
}
onRenderFinished() {
this.onRenderFinishedCallback.forEach(e => {