feat:when in H5 environment,must set check dirty to next macro task loop incase the changing occured in promise.then function which is scheduled in micro task loop
This commit is contained in:
parent
9677207844
commit
4b1fcc439d
@ -733,10 +733,8 @@ class Panel {
|
|||||||
}, undefined);
|
}, undefined);
|
||||||
}
|
}
|
||||||
nativeRender(model) {
|
nativeRender(model) {
|
||||||
if (this.context) {
|
|
||||||
this.context.shader.render(model);
|
this.context.shader.render(model);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
hookBeforeNativeCall() {
|
hookBeforeNativeCall() {
|
||||||
this.__root__.clean();
|
this.__root__.clean();
|
||||||
for (let v of this.headviews.values()) {
|
for (let v of this.headviews.values()) {
|
||||||
@ -745,6 +743,21 @@ class Panel {
|
|||||||
}
|
}
|
||||||
hookAfterNativeCall() {
|
hookAfterNativeCall() {
|
||||||
//Here insert a native call to ensure the promise is resolved done.
|
//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();
|
nativeEmpty();
|
||||||
if (this.__root__.isDirty()) {
|
if (this.__root__.isDirty()) {
|
||||||
const model = this.__root__.toModel();
|
const model = this.__root__.toModel();
|
||||||
@ -758,6 +771,7 @@ class Panel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
__decorate$2([
|
__decorate$2([
|
||||||
NativeCall,
|
NativeCall,
|
||||||
__metadata$2("design:type", Function),
|
__metadata$2("design:type", Function),
|
||||||
|
@ -2181,10 +2181,8 @@ class Panel {
|
|||||||
}, undefined);
|
}, undefined);
|
||||||
}
|
}
|
||||||
nativeRender(model) {
|
nativeRender(model) {
|
||||||
if (this.context) {
|
|
||||||
this.context.shader.render(model);
|
this.context.shader.render(model);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
hookBeforeNativeCall() {
|
hookBeforeNativeCall() {
|
||||||
this.__root__.clean();
|
this.__root__.clean();
|
||||||
for (let v of this.headviews.values()) {
|
for (let v of this.headviews.values()) {
|
||||||
@ -2193,6 +2191,21 @@ class Panel {
|
|||||||
}
|
}
|
||||||
hookAfterNativeCall() {
|
hookAfterNativeCall() {
|
||||||
//Here insert a native call to ensure the promise is resolved done.
|
//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();
|
nativeEmpty();
|
||||||
if (this.__root__.isDirty()) {
|
if (this.__root__.isDirty()) {
|
||||||
const model = this.__root__.toModel();
|
const model = this.__root__.toModel();
|
||||||
@ -2206,6 +2219,7 @@ class Panel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
__decorate$2([
|
__decorate$2([
|
||||||
NativeCall,
|
NativeCall,
|
||||||
__metadata$2("design:type", Function),
|
__metadata$2("design:type", Function),
|
||||||
|
@ -20,7 +20,7 @@ export type BridgeContext = { [index: string]: { [index: string]: (args?: any) =
|
|||||||
declare global {
|
declare global {
|
||||||
const context: BridgeContext
|
const context: BridgeContext
|
||||||
const Environment: {
|
const Environment: {
|
||||||
platform: "Android" | "iOS" | "Qt",
|
platform: "Android" | "iOS" | "Qt" | "h5",
|
||||||
|
|
||||||
platformVersion: string,
|
platformVersion: string,
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ import { View, Group } from "./view"
|
|||||||
import { loge } from '../util/log'
|
import { loge } from '../util/log'
|
||||||
import { Model } from '../util/types'
|
import { Model } from '../util/types'
|
||||||
import { Root } from '../widget/layouts'
|
import { Root } from '../widget/layouts'
|
||||||
|
import { BridgeContext } from '../runtime/global'
|
||||||
|
|
||||||
|
|
||||||
export function NativeCall(target: Panel, propertyKey: string, descriptor: PropertyDescriptor) {
|
export function NativeCall(target: Panel, propertyKey: string, descriptor: PropertyDescriptor) {
|
||||||
@ -34,7 +35,7 @@ type Frame = { width: number, height: number }
|
|||||||
declare function nativeEmpty(): void
|
declare function nativeEmpty(): void
|
||||||
|
|
||||||
export abstract class Panel {
|
export abstract class Panel {
|
||||||
context?: any
|
context!: BridgeContext
|
||||||
onCreate() { }
|
onCreate() { }
|
||||||
onDestroy() { }
|
onDestroy() { }
|
||||||
onShow() { }
|
onShow() { }
|
||||||
@ -139,10 +140,8 @@ export abstract class Panel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private nativeRender(model: Model) {
|
private nativeRender(model: Model) {
|
||||||
if (this.context) {
|
|
||||||
this.context.shader.render(model)
|
this.context.shader.render(model)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private hookBeforeNativeCall() {
|
private hookBeforeNativeCall() {
|
||||||
this.__root__.clean()
|
this.__root__.clean()
|
||||||
@ -153,6 +152,20 @@ export abstract class Panel {
|
|||||||
|
|
||||||
private hookAfterNativeCall() {
|
private hookAfterNativeCall() {
|
||||||
//Here insert a native call to ensure the promise is resolved done.
|
//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()
|
nativeEmpty()
|
||||||
if (this.__root__.isDirty()) {
|
if (this.__root__.isDirty()) {
|
||||||
const model = this.__root__.toModel()
|
const model = this.__root__.toModel()
|
||||||
@ -165,5 +178,6 @@ export abstract class Panel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user