mirror of
https://github.com/tauri-apps/tauri.git
synced 2025-01-01 15:36:14 +03:00
fix(macros): change invoke binding in generate handler (#1804)
This commit is contained in:
parent
144d6b9d4d
commit
7862ec562f
5
.changes/cmd-invoke-binding.md
Normal file
5
.changes/cmd-invoke-binding.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri-macros": patch
|
||||
---
|
||||
|
||||
Fixes a name collision when the command function is named `invoke`.
|
@ -51,12 +51,12 @@ impl From<Handler> for proc_macro::TokenStream {
|
||||
wrappers,
|
||||
}: Handler,
|
||||
) -> Self {
|
||||
quote::quote!(move |invoke| {
|
||||
let __tauri_cmd__ = invoke.message.command();
|
||||
quote::quote!(move |__tauri_invoke__| {
|
||||
let __tauri_cmd__ = __tauri_invoke__.message.command();
|
||||
match __tauri_cmd__ {
|
||||
#(stringify!(#commands) => #wrappers!(#paths, invoke),)*
|
||||
#(stringify!(#commands) => #wrappers!(#paths, __tauri_invoke__),)*
|
||||
_ => {
|
||||
invoke.resolver.reject(format!("command {} not found", __tauri_cmd__))
|
||||
__tauri_invoke__.resolver.reject(format!("command {} not found", __tauri_cmd__))
|
||||
},
|
||||
}
|
||||
})
|
||||
|
@ -7,6 +7,9 @@ use tauri::{command, State};
|
||||
#[command]
|
||||
pub fn cmd(_argument: String) {}
|
||||
|
||||
#[command]
|
||||
pub fn invoke(_argument: String) {}
|
||||
|
||||
#[command]
|
||||
pub fn simple_command(argument: String) {
|
||||
println!("{}", argument);
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
// we move some basic commands to a separate module just to show it works
|
||||
mod commands;
|
||||
use commands::cmd;
|
||||
use commands::{cmd, invoke};
|
||||
|
||||
use serde::Deserialize;
|
||||
use tauri::{command, Params, State, Window};
|
||||
@ -169,6 +169,7 @@ fn main() {
|
||||
commands::simple_command,
|
||||
commands::stateful_command,
|
||||
cmd,
|
||||
invoke,
|
||||
async_simple_command,
|
||||
future_simple_command,
|
||||
async_stateful_command,
|
||||
|
Loading…
Reference in New Issue
Block a user