Re:<dialog>: The Dialog Element
by zelphirkalt on Saturday December 07, 2024 @04:52AM
(#42348563)
Why is it any surprise that one can use await to wait for user input? It is just promises under the hood, right? So that is exactly like one would expect a promise using dialog to work.
[ Parent
| on HN ]
I found that non-obvious too: in both Python and JavaScript I've always seen "await ..." as effectively a hack to enable concurrent execution via an event loop, where the hope is that you won't be waiting very long at all for a response.
Realizing that you could use it for user input - where your promise might not resolve for minutes or even hours - was a bit of a light bulb moment for me.
Indeed, just me being stupid for realizing it so late. Coming from Java and Python 2 I never really understood async/await properly and when I started to grasp it, it took me weeks to realize I could apply it to user interactions too.
Re:<dialog>: The Dialog Element
by lowercased on Saturday December 07, 2024 @12:53PM
(#42351414)
I don't think I've ever seen an example of it used that way in any tutorial, blog, or project documentation ever.