Async Components #3506
Replies: 2 comments
-
|
Beta Was this translation helpful? Give feedback.
-
The current suspension not being async fn is by-design.
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
The current suspension not being async fn is by-design.
|
Beta Was this translation helpful? Give feedback.
-
If this will be not in Yew, someone should consider making an
#[async_component]
anyway.Currently, components that support suspensions look the following way:
This confuses the concepts of
Result
s and the?
operator with the actual intent of it being anawait
ing action. Using that keyword instead, following code can be achieved:This would still mean that the hook is not async and it does some kind of a weird translation from current
Result
toasync
/await
. It would be much better if the future itself could be used instead:#[async_hook]
).async
/await
). This would probably mean thatfn
would be aFuture
then though.await
with?
, replacingHtml
withHtmlResult
, replacing the whole...await
withuse_future(|| ...)?
, and determining that allreturn
s (and last statement of thefn
) should be wrapped inOk
.use_future_with
would be hard to work with?async
call every render. However, the whole way the function components look with their hooks andhtml!
implies declarative approach, rather than imperative, as if we are connecting pieces inside its body, instead of running each line.Beta Was this translation helpful? Give feedback.
All reactions