4 ms·
Thanks! What do you mean by async? At one point Hyperdiv’s frontend was using Svelte and Svelte Material UI components. I explored other options before settlin
by mondrian 3y ago
Thanks! What do you mean by async?
At one point Hyperdiv’s frontend was using Svelte and Svelte Material UI components. I explored other options before settling on shoelace.
Shoelace stuck primarily because it’s very solid and uniform. Ran into very few issues attempting to integrate it. And it being web components allows for a clean and straightforward vanilla JS frontend without dependencies on frontend frameworks. (I love Svelte a lot, but the Hyperdiv Svelte frontend was pretty gnarly.)
- luke-stanley 3y agoThat makes sense, and it makes me wonder what you think about Nicegui, if anything? Re: Async - there could potentially be speed benefits and simplifications if async interfaces were exposed instead of synchronous functions, right? Maybe it's not more simple, maybe async is a trap for the use cases you see that would overcomplicate (totally possible)? Being able to do stuff like await multiple API requests to LLM's and deal with the first to return, or wait for both, is the kinda thing that Python's async interfaces can make easier and I notice that you're already using Tornado for websockets under the hood, which is natively async I think, but the Hyperdiv examples I saw weren't using async functions so I wondered about what the side effects of that could be. Maybe you already have exposed interfaces for it and I've just overlooked them? Edit: I just noticed you said you have async function support! Well, I wonder how deep it goes? I guess you know when something breaks? Anyway really nice presentation of the problem and solution, nice work!
- mondrian 3y agoThanks! Re: nicegui, I like nicegui. Hyperdiv and nicegui are similar in that they're "build web UIs in Python" frameworks but take significantly different approaches. See this comment: https://news.ycombinator.com/item?id=39458641 https://news.ycombinator.com/item?id=39458641 Re: async. Hyperdiv's main function, which generates the UI, runs synchronously, indeed. But the main function can spawn off asynchronous calls. For example: async def api_call(): data = await get_data() return data def main(): task = hd.task() task.run(api_call) if not task.done: hd.spinner() else: hd.text("Loaded data:", task.result) This app spins off an async call to api_call(). While the call is running in the background, a loading spinner is displayed. When the task finishes, its return value is rendered. Async tasks can also update state gradually while they run: async def api_calls(state): data1 = await get_data1() state.data1 = data1 data2 = await get_data2() state.data2 = data2 def main(): state = hd.state(data1=None, data2=None) task = hd.task() task.run(api_calls, state) hd.text("Data1:", state.data1) hd.text("Data2:", state.data2) This app will initially display "Data1: None\nData2: None". When get_data1() finishes running, the UI updates to show the result for "Data1", but the result for "Data2" is still None. When `get_data2()` finishes running, both fields are then filled. You can also write an async function that runs indefinitely, continually listening on some I/O channel and updating state as new data arrives. When the app exits, it can signal the task to exit.
- luke-stanley 3y agoThat's cool and I imagine it supports a lot of the situations async users would need. Thanks for your great explanation. Having a more clean, declarative state is a great differentiation from Nicegui. This is a great contribution, I wish you the best of luck to you!