News for hackers. Stuff that matters.
Re:Show HN: Async UI: A Rust UI Library Where Everything is ... by wishawa on Wednesday October 05, 2022 @12:05AM (#33091090)
You're right that components should intuitively pend forever. But with Async UI, the line between a component and a normal async function is blurry; our login_form eventually returns, so it is a normal async function, but it also renders something, so it is kind of a component...

Concretely the login_form function works by racing a render (a true, never-completing component) with a "listener" future that completes when the user submits their login. Once the listener completes, the race is over and the render future gets dropped. We can then return from login_form.

Re:Show HN: Async UI: A Rust UI Library Where Everything is ... by lucasyvas on Wednesday October 05, 2022 @12:26AM (#33091231)
This pretty interesting - does it take inspiration from anything? I personally haven't seen anything like this.

It would also be great to see example code for that - it's the most significant part where I was looking for more information but couldn't find it.

Edit: A bit unrelated, but the tokio vs async-std split continues!

Edit 2: How does error handling work? Is check_login a component or regular request?

Re:Show HN: Async UI: A Rust UI Library Where Everything is ... by wishawa on Wednesday October 05, 2022 @01:06AM (#33091495)
The async control flow is not directly inspired by anything. It is a cool side effect of using async for everything that I myself only discovered once I started writing examples.

Async UI as a whole is inspired by the simple fact that UI is an effect system[1], and async is also an effect system.

[1]: https://en.wikipedia.org/wiki/Effect_system

Re async split: Diversity promotes innovation :)

Re error handling: There's no real support yet. For now when I hit an error I just render nothing. I might add support for components returning Result<_, _> in the future.

Re:Show HN: Async UI: A Rust UI Library Where Everything is ... by kwkelly on Wednesday October 05, 2022 @06:45AM (#33093684)
Crank.js uses async and races for control flow. It’s pretty interesting
Re:Show HN: Async UI: A Rust UI Library Where Everything is ... by wishawa on Wednesday October 05, 2022 @12:54AM (#33091414)
The full example code is here: https://github.com/wishawa/async_ui/blob/main/examples/gtk-l....

(except for that invalid_login_popup is not a real popup because I haven't implemented popups yet)

I'll add a link to it in the blog post.