How to call async rust code from js
See original GitHub issueI have some very time-consuming tasks in rust, if I use invoke_handler
and call then from js, my UI stucked.
Is there any way to call async rust code from js, or can invoke_handler except Future?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
A practical guide to async in Rust - LogRocket Blog
If you're writing an asynchronous program in Rust or using an async library for the first time, this tutorial can help you get...
Read more >call async javascript function from rust - denoland/deno - GitHub
Hi! TL;DR: Is it possible to call a javascript async function (or callback/closure) from rust like this: javascript_function.call_async( ...
Read more >async/.await Primer - Asynchronous Programming in Rust
async / .await is Rust's built-in tool for writing asynchronous functions that look like synchronous code. async transforms a block of code into...
Read more >How to call an async JavaScript Import Function from ...
I'm using wasm-pack, with which I build the wasm-module and glue code (using the node.js-target). For importing the functions I use a Javascript...
Read more >Calling async function from main() - Rust Users Forum
The easiest way is to make main async. To do this you need the #[tokio::main] macro. As an alternative to this, you can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can spawn a new thread (or maybe a tokio task, or send the task payload via a queue to a worker pool) from the invoke handler. Pass to the new thread a
Handle
. When the work is done, pass the result back to js viadispatch
andeval
.Closing the issue, some async processing can be seen in examples. If you need to clarify something, feel free to reopen this.