class TextFetcher { output: TextBlock problem: TextBlock status: TextBlock task: Object function apply(self: TextFetcher): Unit { self.output.text = self.task.result() } function fetch(self: TextFetcher, url: String): Unit { self.task = ui.fetchText(self, "request", url, self.apply) self.output.text = "" self.status.bind("text", self.task.status) self.problem.bind("text", self.task.error) } } output = TextBlock("尚未请求网络") problem = TextBlock("") status = TextBlock("") fetcher = TextFetcher(output, problem, status, ui.state(0)) page = Page() page.title = "异步网络" page.render(Column(24,16,TextBlock("在 REPL 调用 fetcher.fetch(HTTP 或 HTTPS 地址字符串)",2),status,problem,output))