Crates.io | tauri-async-handler |
lib.rs | tauri-async-handler |
version | 0.4.0 |
source | src |
created_at | 2020-06-13 12:08:54.635705 |
updated_at | 2021-01-11 17:23:37.315234 |
description | A async handler for tauri |
homepage | |
repository | https://github.com/spacemeowx2/tauri-async-handler |
max_upload_size | |
id | 253528 |
size | 6,559 |
Cargo.toml:
[dependencies]
tauri-async-handler = "0.1"
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))