feat:refact View Dirty Props,prepare to use in ListView
This commit is contained in:
@@ -44,6 +44,10 @@ export class List extends Superview {
|
||||
return this.cachedViews.get(id)
|
||||
}
|
||||
|
||||
allSubviews() {
|
||||
return this.cachedViews.values()
|
||||
}
|
||||
|
||||
@Property
|
||||
itemCount = 0
|
||||
|
||||
|
@@ -99,8 +99,8 @@ export abstract class Panel {
|
||||
|
||||
private retrospectView(ids: string[]): View {
|
||||
return ids.reduce((acc: View, cur) => {
|
||||
if (Reflect.has(acc, "subViewById")) {
|
||||
return Reflect.apply(Reflect.get(acc, "subViewById"), acc, [cur])
|
||||
if (Reflect.has(acc, "subviewById")) {
|
||||
return Reflect.apply(Reflect.get(acc, "subviewById"), acc, [cur])
|
||||
}
|
||||
return acc
|
||||
}, this.__root__)
|
||||
|
@@ -254,6 +254,20 @@ export abstract class View implements Modeling, IView {
|
||||
|
||||
export abstract class Superview extends View {
|
||||
abstract subviewById(id: string): View | undefined
|
||||
abstract allSubviews(): Iterable<View>
|
||||
|
||||
isDirty() {
|
||||
if (super.isDirty()) {
|
||||
return true
|
||||
} else {
|
||||
for (const v of this.allSubviews()) {
|
||||
if (v.isDirty()) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
export abstract class Group extends Superview {
|
||||
@@ -276,6 +290,10 @@ export abstract class Group extends Superview {
|
||||
return undefined
|
||||
}
|
||||
|
||||
allSubviews() {
|
||||
return this.children
|
||||
}
|
||||
|
||||
addChild(view: View) {
|
||||
this.children.push(view)
|
||||
}
|
||||
|
Reference in New Issue
Block a user