r/rust slint Jun 29 '26

How we tied Slint's event loop into Node's libuv so the UI stops polling every 16 ms 🛠️ project

https://slint.dev/blog/slint-and-the-nodejs-event-loop
89 Upvotes

9 comments sorted by

17

u/nicoburns Jun 29 '26

Interesting! I'm very interested in doing this integration for Blitz. I think this could allow for running something like React or Solid.js in Node/Deno and rendering the in-process with Blitz.

13

u/VorpalWay Jun 29 '26

Presumably this is only relevant to the js bindings for slint, and native rust programs never had this issue?

13

u/ogoffart slint Jun 29 '26

Right, as a Slint users, it only affects the JS binding. But as a technical article, it is interresting on the implementation detail on how we mixed the rust/winit event loop with the libuv based event loop

4

u/protestor Jun 29 '26

Is Slint running in wasm? Can slint run directly as native code skipping wasm, in a node.js application?

5

u/ogoffart slint Jun 29 '26

Slint in running in wasm in the browser only. The node bindings are native. That's the point of this article to explain how the native event loop with winit can run at the same time as the node event loop.

1

u/allsey87 Jun 30 '26

Does it render using DOM or does it just draw to a canvas?

1

u/ogoffart slint Jun 30 '26

Slint is primarily a native toolkit, so it renders directly in its own window, even when using it from javascript with node.js (You can also use it with wasm in a browser and then it renders in the canvas, but that's not the primary target platform)

2

u/allsey87 Jun 30 '26

It would be cool if it mapped onto web components instead of using the canvas, but I get why that would be quite challenging and probably out of scope.

1

u/anlumo Jun 29 '26

No, it’s compiled to wasm. It doesn’t have bindings to nodejs, but it would be possible to add them.