let data = await invoke("get_test_data"); //Data should be {Name : "Test"}
To receive data on the backend, you do this:
#[tauri::command]
fn set_test_data(data : Value) {
let mut entity : Entity = Entity::new();
let name : Name = serde_json::from_value(data["Name"].clone()).unwrap();
let damage : Damage = serde_json::from_value(data["Damage"].clone()).unwrap();
entity.add(name);
entity.add(damage);
println!("Test {}", entity.to_string());
}
Sadly there is no functions that can do this nicely. Data that coms from the frontend must be sorted out by the backend. To send data from the front end you do this:
This PR is a small one, and is related to issue #26. This PR adds:
Entity
struct now implements Serialize.Entity
structs can now be returned in atauri
command to be sent to the frontend.TS
should now generate typescript types that match their serde translationTo send data over a command, you have to have something like this:
and on the front end you do this:
To receive data on the backend, you do this:
Sadly there is no functions that can do this nicely. Data that coms from the frontend must be sorted out by the backend. To send data from the front end you do this: