Skip to content

How to add async/await inside the listen events #4959

Answered by FabianLars
sdicker8 asked this question in Q&A
Discussion options

You must be logged in to vote

The last messages in that thread go somewhat in the right direction. 1) It's actually quite rare that you really need tokio::main _in a tauri app. 2) if you still want to do it (which is fine btw), you need to give Tauri a handle to the tokio runtime: https://docs.rs/tauri/latest/tauri/async_runtime/fn.set.html

Edit: It gets a little weird inside the on_X_event handlers, you need to wrap the async_runtime::block_on call in tauri::task::block_in_place :/

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by FabianLars
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