Non-exposed/serialized argument in #[command] #2304
-
This is kind of hard to explain in a short sentence, so apologies if the title isn't very descriptive. Basically, I'd like to make something like this work: #[command]
fn command_one(js_arg: i32, ...) {
println!("Just a normal command.");
}
#[command]
fn command_two(argument_js_cant_pass: &T, other_args_js_can_pass: V) {
}
fn main() {
let some_value_some_commands_want: T = ...;
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![command_one, command_two])
.run(tauri::generate_context!())
.expect("error while running tauri application");
} Where I think this could theoretically be done with a custom invoke_handler, but Overall though, implementing my own version of If a change were to be made in Tauri to facilitate the above (if it's not already possible), it would perhaps take some extra attr to As an aside, I poked around a relevant issue/PR or two and it seems In any case, some help here would really be appreciated, as I'm not really sure how to continue/if I can continue until I have a solution to this. Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
What about using state? As you suggested a use_state thingy yourself I think that's exactly what you'd want? |
Beta Was this translation helpful? Give feedback.
What about using state?
See: https://tauri.studio/en/docs/guides/command/#accessing-managed-state
And: https://github.com/tauri-apps/tauri/tree/dev/examples/state
And while we're at it this one too: https://github.com/tauri-apps/tauri/tree/dev/examples/commands
As you suggested a use_state thingy yourself I think that's exactly what you'd want?