Node callbacks not working · Issue #2477 · slint

您所在的位置:网站首页 都市天际线创意工坊中文 Node callbacks not working · Issue #2477 · slint

Node callbacks not working · Issue #2477 · slint

#Node callbacks not working · Issue #2477 · slint| 来源: 网络整理| 查看: 265

Originally posted by arturolinares January 14, 2023 Hi! I am having trouble using the slint-ui with node in a small application.

I have a window with a button that when it is clicked makes a request to Google and updates the button text to the response body length. The UI appears to work well, except that the request doesn't seem to finish until the window is closed. Maybe I need to perform the request outside the UI thread... but how can I do that?

Peek 13-01-2023 19-45

This is the script:

const slint = require("slint-ui"); const ui = require("./ui/main.slint"); const fetch = require('node-fetch'); function doFetch() { fetch('https://google.com') .then(r => r.text()) .then(text => { console.log("Update button text"); app.MainButton.text = text.length; }); } let app = new ui.MainWindow({ clicked: () => doFetch() }); app.run();

The slint file:

import { Button } from "std-widgets.slint"; export MainWindow := Window { callback clicked MainButton.clicked; MainButton := Button { text: "Click Me!"; } }

Thanks in advance 😄



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3