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.
Uh oh!
There was an error while loading. Please reload this page.
-
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
Results and the?operator with the actual intent of it being anawaiting 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
Resulttoasync/await. It would be much better if the future itself could be used instead:#[async_hook]).async/await). This would probably mean thatfnwould be aFuturethen though.awaitwith?, replacingHtmlwithHtmlResult, replacing the whole...awaitwithuse_future(|| ...)?, and determining that allreturns (and last statement of thefn) should be wrapped inOk.use_future_withwould be hard to work with?asynccall 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