#How to invoke command from Rust

5 messages · Page 1 of 1 (latest)

opaque ravine
#

In the documentation there’s only guide to invoke command from JS but sometimes I want to do it from Rust too.
It’s not obvious as just calling the Rust function because there might be app handle and state involved.

golden egret
#

hmm, you can't really "just" invoke a command from the rust side. Rust isn't "dynamic" enough for that.

#

the closes thing, if you can't move around an AppHandle manually, is to store a global-ish AppHandle in a OnceCell from the setup hook (the earliest point in time where you can get one)

#

then you can use that apphandle to get AppHandle, Window, and State for the command which you call like a regular rust function at that point.

sturdy nebula
#

I have an AppHandle<A> available from builder.on_menu_event(|app| ...) which is generic over A, but I want to call a command which needs a AppHandle<tauri_runtime_wry::Wry<EventLoopMessage>> how can I upgrade my handle?