about App and AppHandle struct #8526
-
Hi, I'm begining with tauri to build my app, I think rust+js is the best solution what I want on cross platform develop. I want save a app instance in my own SomeApp struct, then I can do everything(for example: window create/destory, shortcut setting/ menu setting/ about info create/ ... ) base on it. I understand plugin is inited on builder and not on App, because plugin is global concept behind the App. In the builder doc, there is a invoke_system method, which I don't understand it's function and usage... Is there some method to create app with no builder? Is there some detail doc to help me create tauri app with lowerest api which can help me got the concept relationships on step by step code to create app's everything like tray/menu/about/event/window/window manage/.... I'm sorry, I have very much confuses with tauri api, because not familar with it and rust, So, Can you give me some advice? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
You basically always want an The difference between App and AppHandle is really just that the AppHandle is a handle or a reference to the instance of App (concept wise similar-ish to
Use an AppHandle
You can register a plugin on the App/AppHandle too https://docs.rs/tauri/latest/tauri/struct.AppHandle.html#method.plugin
We probably could change that, not sure. But since you can register Plugins at runtime you can register new commands in plugins instead.
If that's the case you likely don't need it. It was added for this library: https://github.com/tauri-apps/tauri-invoke-http/ which replaces the default invoke system (the IPC, the transport between js and rust), which uses native webview apis, with a standard http server.
No.
I don't really understand what you're actually asking for. |
Beta Was this translation helpful? Give feedback.
You basically always want an
AppHandle
. It's also the only thing you can move into threads for example. You only useApp
if you get it from tauri directly, for example in the Builder'ssetup
hook. But then again, once you have to move that into a different context (a thread, or a struct member) you'd want to get an AppHandle viaapp.handle()
.The difference between App and AppHandle is really just that the AppHandle is a handle or a reference to the instance of App (concept wise similar-ish to
&
in rust if that helps). You can have multiple AppHandle instances but only one App == You can have multiple references to your main app but you can only have on actual app.