#Tauri rust functions hanging
1 messages · Page 1 of 1 (latest)
Lets see my_cool_function
Most likely the issue is in the function code and not in Tauri itself
#[tauri::command]
fn start_discord_rpc() -> String {
println!("[RUST] DiscordRPC requested to be started by JS.");
println!("[RUST] DiscordRPC connected to Client.");
return "T".to_string();
}
.invoke_handler(tauri::generate_handler![start_discord_rpc])
console.log(await window.__TAURI__.invoke("start_discord_rpc"));
what the
Do you have withGlobalTauri enabled?
And can I see your full main() function?
fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_log::Builder::default().targets([
Target::new(TargetKind::Stdout),
Target::new(TargetKind::Webview),
]).build())
.invoke_handler(tauri::generate_handler![start_discord_rpc])
.invoke_handler(tauri::generate_handler![set_discord_rpc])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
"build": {
"beforeDevCommand": "yarn dev",
"beforeBuildCommand": "yarn build",
"devPath": "http://localhost:5173",
"distDir": "../dist",
"withGlobalTauri": true
},
This is wrong. You should only use invoke_handler once
.invoke_handler(tauri::generate_handler![start_discord_rpc, set_discord_rpc])