question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to call async rust code from js

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sopiumcommented, Jan 20, 2020

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 via dispatch and eval.

0reactions
zxeycommented, Feb 26, 2020

Closing the issue, some async processing can be seen in examples. If you need to clarify something, feel free to reopen this.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found