Expand description
§Usage
Cargo.toml:
[dependencies]
tauri-async-handler = "0.4"
src-tauri/main.rs:
mod cmd;
use serde_json::json;
use tauri_async_handler::*;
fn main() {
tauri::AppBuilder::new()
.async_handler(None, |cmd: cmd::Cmd| async {
use cmd::Cmd::*;
Ok(match cmd {
MyCustomCommand{ argument } => {
println!("arg {}", argument);
let world = "world";
json!({
"hello": world
})
}
})
})
.build()
.run();
}
JavaScript:
const myCustomCommand = (argument) => {
return window.tauri.promisified({
cmd: 'myCustomCommand',
argument,
})
}
myCustomCommand.then((r) => console.log('myCustomCommand', r))