Function tauri::async_runtime::set

source ·
pub fn set(handle: TokioHandle)
Expand description

Sets the runtime to use to execute asynchronous tasks. For convenience, this method takes a TokioHandle. Note that you cannot drop the underlying TokioRuntime.

§Examples

#[tokio::main]
async fn main() {
  // perform some async task before initializing the app
  do_something().await;
  // share the current runtime with Tauri
  tauri::async_runtime::set(tokio::runtime::Handle::current());

  // bootstrap the tauri app...
  // tauri::Builder::default().run().unwrap();
}

async fn do_something() {}

§Panics

Panics if the runtime is already set.