feat: notify Endor objects of mount lifecycle transitions
Verify Tessera GUI / verify (push) Failing after 7m23s
Verify Tessera GUI / verify (push) Failing after 7m23s
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
| File | Purpose |
|
||||
| --- | --- |
|
||||
| [mount-lifecycle.endor](mount-lifecycle.endor) | Source onMount/onUnmount methods, two occurrences of one object, ordered notifications and retained Mount lifetime. |
|
||||
| [events.endor](events.endor) | Managed event subscriptions, source onEvent override and numbered capture/target/bubble steps from native input. |
|
||||
| [native-subclasses.endor](native-subclasses.endor) | Real native TextBlock/Button/Page source subclasses, inherited fields, method overrides and shared field bindings. |
|
||||
| [classes.endor](classes.endor) | Endor class fields, inheritance, overriding, a retained receiver and Event arguments; native keyboard input updates shared model properties. |
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
class LifecycleLog {
|
||||
order: Object
|
||||
mounted: Object
|
||||
unmounted: Object
|
||||
parentMounted: Number
|
||||
childMounted: Number
|
||||
parentUnmounted: Number
|
||||
childUnmounted: Number
|
||||
latest: Object
|
||||
}
|
||||
class WatchedText: TextBlock {
|
||||
log: LifecycleLog
|
||||
function onMount(self: WatchedText, mount: Mount): Unit {
|
||||
self.log.order.increment()
|
||||
self.log.mounted.increment()
|
||||
self.log.childMounted = self.log.order.value
|
||||
self.log.latest.set(mount)
|
||||
self.setText("同一个对象,两个独立挂载位置")
|
||||
}
|
||||
function onUnmount(self: WatchedText, mount: Mount): Unit {
|
||||
self.log.order.increment()
|
||||
self.log.unmounted.increment()
|
||||
self.log.childUnmounted = self.log.order.value
|
||||
self.log.latest.set(mount)
|
||||
}
|
||||
}
|
||||
class WatchedColumn: Column {
|
||||
log: LifecycleLog
|
||||
function onMount(self: WatchedColumn, mount: Mount): Unit {
|
||||
self.log.order.increment()
|
||||
self.log.parentMounted = self.log.order.value
|
||||
}
|
||||
function onUnmount(self: WatchedColumn, mount: Mount): Unit {
|
||||
self.log.order.increment()
|
||||
self.log.parentUnmounted = self.log.order.value
|
||||
}
|
||||
}
|
||||
log = LifecycleLog(ui.state(0), ui.state(0), ui.state(0), 0, 0, 0, 0, ui.state(0))
|
||||
child = WatchedText("等待挂载", 2, log)
|
||||
root = WatchedColumn(24, 16, child, child, TextBlock("挂载次数"), ui.textOf(log.mounted, "value"), TextBlock("卸载次数"), ui.textOf(log.unmounted, "value"), log)
|
||||
page = Page()
|
||||
page.render(root)
|
||||
Reference in New Issue
Block a user