File tree Expand file tree Collapse file tree 3 files changed +17
-0
lines changed
Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,12 @@ fn goodbye_world() -> impl Serialize + specta::Type {
2424 "Goodbye world :("
2525}
2626
27+ #[ tauri:: command]
28+ #[ specta:: specta]
29+ async fn async_hello_world ( my_name : String ) -> String {
30+ format ! ( "Hello, {my_name}!" )
31+ }
32+
2733#[ tauri:: command]
2834#[ specta:: specta]
2935fn has_error ( ) -> Result < & ' static str , i32 > {
@@ -121,6 +127,7 @@ fn main() {
121127 . commands ( tauri_specta:: collect_commands![
122128 hello_world,
123129 goodbye_world,
130+ async_hello_world,
124131 has_error,
125132 nested:: some_struct,
126133 generic:: <tauri:: Wry >,
Original file line number Diff line number Diff line change @@ -20,6 +20,13 @@ async helloWorld(myName) {
2020async goodbyeWorld ( ) {
2121 return await TAURI_INVOKE ( "goodbye_world" ) ;
2222} ,
23+ /**
24+ * @param { string } myName
25+ * @returns { Promise<string> }
26+ */
27+ async asyncHelloWorld ( myName ) {
28+ return await TAURI_INVOKE ( "async_hello_world" , { myName } ) ;
29+ } ,
2330/**
2431 * @returns { Promise<Result<string, number>> }
2532 */
Original file line number Diff line number Diff line change @@ -16,6 +16,9 @@ async helloWorld(myName: string) : Promise<string> {
1616async goodbyeWorld ( ) : Promise < string > {
1717 return await TAURI_INVOKE ( "goodbye_world" ) ;
1818} ,
19+ async asyncHelloWorld ( myName : string ) : Promise < string > {
20+ return await TAURI_INVOKE ( "async_hello_world" , { myName } ) ;
21+ } ,
1922async hasError ( ) : Promise < Result < string , number > > {
2023 try {
2124 return { status : "ok" , data : await TAURI_INVOKE ( "has_error" ) } ;
You can’t perform that action at this time.
0 commit comments