js:adjust hook timing for nested situation
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import '../runtime/global'
|
||||
import { View, Group } from "./view"
|
||||
import { loge } from '../util/log'
|
||||
import { Model } from '../util/types'
|
||||
@@ -31,6 +30,8 @@ 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() { }
|
||||
@@ -141,24 +142,43 @@ export abstract class Panel {
|
||||
}
|
||||
|
||||
private hookBeforeNativeCall() {
|
||||
if (Environment.platform !== 'h5') {
|
||||
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.
|
||||
Promise.resolve().then(() => {
|
||||
if (Environment.platform !== 'h5') {
|
||||
//Here insert a native call to ensure the promise is resolved done.
|
||||
nativeEmpty()
|
||||
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()
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
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()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user