How to emit Tauri backend (rust) event from new thread spawn outside of Builder?

306 views Asked by At

I have a rust code in tauri app which browse bonjour services using mdns-sd and when found should pass it to the frontend using tauri event system. The Tauri documentation explains how to emit event from inside the Builder function, but i have a loop running in separate thread spawn before the Builder runs:

...
fn main () {
   ...
   std::thread::spawn(move || {
        //browse for services here and need to pass it to frontend as found
   });
   
   tauri::Builder::default().setup...
...
}

I have tried to move spawning the thread inside the .setup of Builder, but the app property is anyway unavailable inside thread even when it's there.

0

There are 0 answers