Invoke handler delegation/adapter? #11471
Unanswered
stijnfrishert
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey everyone,
I have a crate that already has a bunch of functions under the
api
module. I feed these into an Lua interpreter, to enable changing my document through scripting. They're all of the form:I would like to expose these as Tauri commands well, providing the same API in my frontend through js/ts. In Tauri, the
Editor
is part of the App state (Mutex<Editor>
), so the command would be something along the lines of:I would very much like to avoid duplicating every API entry point like this. It's not only tedious, but also prone to copy/paste bugs or forgetting to do the work.
What is the best way to go about this? I was looking at the implementation of invoke handlers, but the code specifically states everything these is internal and subject to change.
Is there a way to write a set of command handlers that all have
tauri::State<Mutex<Editor>>>
, retrieve the editor and then delegate to my actual API functions?Beta Was this translation helpful? Give feedback.
All reactions