Add API for synchronous rendering to Panel

This commit is contained in:
pengfei.zhou
2023-02-15 16:31:28 +08:00
committed by osborn
parent fc4628dde9
commit 37e93273b8
19 changed files with 269 additions and 10 deletions

View File

@@ -1327,6 +1327,48 @@ var Panel = /** @class */ (function () {
});
}
};
Panel.prototype.__fetchEffectiveData__ = function () {
var e_4, _a, e_5, _b;
var diryData = [];
if (this.destroyed) {
return diryData;
}
if (this.__root__.isDirty()) {
var model = this.__root__.toModel();
diryData.push(JSON.parse(JSON.stringify(model)));
this.__root__.clean();
}
try {
for (var _c = __values$3(this.headviews.values()), _d = _c.next(); !_d.done; _d = _c.next()) {
var map = _d.value;
try {
for (var _e = (e_5 = void 0, __values$3(map.values())), _f = _e.next(); !_f.done; _f = _e.next()) {
var v = _f.value;
if (v.isDirty()) {
var model = v.toModel();
diryData.push(JSON.parse(JSON.stringify(model)));
v.clean();
}
}
}
catch (e_5_1) { e_5 = { error: e_5_1 }; }
finally {
try {
if (_f && !_f.done && (_b = _e.return)) { _b.call(_e); }
}
finally { if (e_5) { throw e_5.error; } }
}
}
}
catch (e_4_1) { e_4 = { error: e_4_1 }; }
finally {
try {
if (_d && !_d.done && (_a = _c.return)) { _a.call(_c); }
}
finally { if (e_4) { throw e_4.error; } }
}
return diryData;
};
Panel.prototype.onRenderFinished = function () {
this.onRenderFinishedCallback.forEach(function (e) {
e();

View File

@@ -1026,6 +1026,27 @@ class Panel {
});
}
}
__fetchEffectiveData__() {
const diryData = [];
if (this.destroyed) {
return diryData;
}
if (this.__root__.isDirty()) {
const model = this.__root__.toModel();
diryData.push(JSON.parse(JSON.stringify(model)));
this.__root__.clean();
}
for (let map of this.headviews.values()) {
for (let v of map.values()) {
if (v.isDirty()) {
const model = v.toModel();
diryData.push(JSON.parse(JSON.stringify(model)));
v.clean();
}
}
}
return diryData;
}
onRenderFinished() {
this.onRenderFinishedCallback.forEach(e => {
e();

View File

@@ -2566,6 +2566,27 @@ class Panel {
});
}
}
__fetchEffectiveData__() {
const diryData = [];
if (this.destroyed) {
return diryData;
}
if (this.__root__.isDirty()) {
const model = this.__root__.toModel();
diryData.push(JSON.parse(JSON.stringify(model)));
this.__root__.clean();
}
for (let map of this.headviews.values()) {
for (let v of map.values()) {
if (v.isDirty()) {
const model = v.toModel();
diryData.push(JSON.parse(JSON.stringify(model)));
v.clean();
}
}
}
return diryData;
}
onRenderFinished() {
this.onRenderFinishedCallback.forEach(e => {
e();

1
doric-js/index.d.ts vendored
View File

@@ -741,6 +741,7 @@ declare module "doric" {
private nativeRender;
private hookBeforeNativeCall;
private hookAfterNativeCall;
private __fetchEffectiveData__;
onRenderFinished(): void;
addOnRenderFinishedCallback(cb: () => void): void;
}

View File

@@ -44,6 +44,7 @@ export declare abstract class Panel {
private nativeRender;
private hookBeforeNativeCall;
private hookAfterNativeCall;
private __fetchEffectiveData__;
onRenderFinished(): void;
addOnRenderFinishedCallback(cb: () => void): void;
}

View File

@@ -199,6 +199,27 @@ export class Panel {
});
}
}
__fetchEffectiveData__() {
const diryData = [];
if (this.destroyed) {
return diryData;
}
if (this.__root__.isDirty()) {
const model = this.__root__.toModel();
diryData.push(JSON.parse(JSON.stringify(model)));
this.__root__.clean();
}
for (let map of this.headviews.values()) {
for (let v of map.values()) {
if (v.isDirty()) {
const model = v.toModel();
diryData.push(JSON.parse(JSON.stringify(model)));
v.clean();
}
}
}
return diryData;
}
onRenderFinished() {
this.onRenderFinishedCallback.forEach(e => {
e();

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { View, Group } from "./view"
import { View, Group, NativeViewModel } from "./view"
import { loge } from '../util/log'
import { Model } from '../util/types'
import { Root } from '../widget/layouts'
@@ -234,6 +234,28 @@ export abstract class Panel {
}
}
private __fetchEffectiveData__() {
const diryData: NativeViewModel[] = [];
if (this.destroyed) {
return diryData;
}
if (this.__root__.isDirty()) {
const model = this.__root__.toModel()
diryData.push(JSON.parse(JSON.stringify(model)));
this.__root__.clean();
}
for (let map of this.headviews.values()) {
for (let v of map.values()) {
if (v.isDirty()) {
const model = v.toModel()
diryData.push(JSON.parse(JSON.stringify(model)));
v.clean();
}
}
}
return diryData;
}
onRenderFinished() {
this.onRenderFinishedCallback.forEach(e => {
e()