Skip to content

Help with async fetch #3195

Closed Answered by jedel1043
mlafeldt asked this question in Q&A
Aug 2, 2023 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

Yeah, the main problem here is that you need to use the &mut Context reference after awaiting, which catches the mutable reference and makes the whole future not static. Fortunately, we added an escape hatch to the async API where you can de-sugar the utility function into its internal representation as a future job, which removes this limitation with the downside of some increased verbosity:

let (promise, resolvers) = Self::new_pending(context);
let future = async move {
let result = future.await;
NativeJob::new(move |context| match result {
Ok(v) => resolvers.resolve.call(&

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@jedel1043
Comment options

Answer selected by mlafeldt
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants