Own asynchronous timer tasks in the managed object lifecycle
Verify Tessera GUI / verify (push) Failing after 7m26s
Verify Tessera GUI / verify (push) Failing after 7m26s
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
class Actions {
|
||||
owner: Object
|
||||
state: Object
|
||||
function complete(self: Actions): Unit { self.state.increment() }
|
||||
function schedule(self: Actions, event: Event): Unit {
|
||||
ui.after(self.owner, "load", 1500, self.complete)
|
||||
}
|
||||
}
|
||||
state = ui.state(0)
|
||||
hidden = TextBlock("这个 Block 没有挂载,也能拥有任务")
|
||||
page = Page()
|
||||
page.title = "任务生命周期"
|
||||
pageActions = Actions(page, state)
|
||||
blockActions = Actions(hidden, state)
|
||||
appActions = Actions(ui, state)
|
||||
pageButton = Button("Page 任务:关闭 Tab 会取消")
|
||||
blockButton = Button("隐藏 Block 任务:关闭 Tab 仍继续")
|
||||
appButton = Button("应用任务:关闭 Tab 仍继续")
|
||||
pageConnection = pageButton.on("click", pageActions.schedule)
|
||||
blockConnection = blockButton.on("click", blockActions.schedule)
|
||||
appConnection = appButton.on("click", appActions.schedule)
|
||||
page.render(Column(24, 16, TextBlock("1.5 秒后更新同一个状态对象;重复点击只保留最新任务"), ui.textOf(state, "value"), pageButton, blockButton, appButton))
|
||||
initial = ui.after(ui, "initial", 500, appActions.complete)
|
||||
ui.window().setTitle("Owned Tasks")
|
||||
Reference in New Issue
Block a user