New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include updated documentation on best practices related to making requests or doing other asynchronous operations inside Yew components #2837
Comments
How common is it for you to perform some async action and |
I mean, this seems like the standard way to do this, outside of using Using |
There's a section on fetching data in the tutorial. I'm not sure if we need a specific section for it in the documentation. Maybe we can add a "Promises with Also on master, there's use_future/use_future_with_deps available to be used with |
Purely from a documentation standpoint, a "Working with async" makes sense, addressing how js promises are converted like you said, but also give an overview of the |
@hamza1311 There's no guidance on that page for doing anything similar with non-function components, fyi. From a user's standpoint, I think it'd be helpful to add a new section to the docs entirely, or update the tutorial to accomodate other types of components, or some combination of the 2. |
Also - just to anyone who stumbles upon this: I've found the most concise way to handle async requests within a component lifecycle function (like
I find this to be a lot more concise than what's currently in the tutorial, plus it lets you access the lifecycle of the component and avoid some of the hook-cloning that's inevitable when you use |
This is about:
Problem
Currently, there is nothing in the documentation for Yew 0.19 on making requests or doing other asynchronous operations inside of components or function components. Since the removal of the fetch service, the documentation recommends switching to libraries like
reqwest
for making API calls, but there are no code examples or best practices for how to do so. While this can be easily accomplished with libraries likeyew-hooks
orwasm-bindgen
(which, afaik only work in function components) I'd like to see some instructions, agreed on by the overall community, that would help new Yewsers like myself.The process of figuring out how to go about doing this is difficult (especially with components not allowing the
async
keyword on lifetime methods likecreate
orupdate)
, and from what I can tell there's not really even a standardized way of going about it.Questionaire (Optional)
The text was updated successfully, but these errors were encountered: