Redraw on resolve of async event handler #2912
EtiamNullam
started this conversation in
Ideas
Replies: 1 comment
-
Highly related: #2681 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is this something you're interested in implementing yourself? Yes
Description
I believe interacting with async code can be improved if we always redraw on resolve of promise from event handlers. Consider this simple app, where we need to manually call
m.redraw()
after a (fake) long async operation completes which originated from user action (button click):If Mithril's premise is to quickly update after every user interaction then we should also watch for resolve of that action if given opportunity, so my suggestion is to redraw when promise from event handler is resolved.
Why
I believe that's what everyone expects from an async event handler. It seems convenient to me.
Possible Implementation
We are already checking the result of event handler just to see if event propagation should be skipped in case it returned
false
. In the same place we can check if returned value from event handler looks like promise and attachm.redraw()
once it's resolved.Note
I'm linking to thread I've started on Zulip: https://mithril.zulipchat.com/#narrow/stream/324076-general/topic/Async.20event.20handlers
Beta Was this translation helpful? Give feedback.
All reactions