Change SetupHook
from Box<dyn Fn(...)...>
to Box<dyn FnOnce(...)...>
#3061
Labels
SetupHook
from Box<dyn Fn(...)...>
to Box<dyn FnOnce(...)...>
#3061
Is your feature request related to a problem? Please describe.
The
SetupHook
type utilizesFn()
instead ofFnOnce()
, even though it is only run once. This prevents users from moving values into the setup closure ontauri::Builder
, and makes it so that users have to utilize extra workarounds to achieve the result that they're looking for.Describe the solution you'd like
Change the
SetupHook
type toBox<dyn FnOnce(&mut App<R>) -> Result<(), Box<dyn std::error::Error + Send>> + Send>
, and change theF
generic parameter intauri::Builder::setup
toFnOnce(&mut App<R>) -> Result<(), Box<dyn std::error::Error + Send>> + Send + 'static
. As far as I can tell (and have tested), this should be totally possible, sincesetup
is only run once, here.Describe alternatives you've considered
As far as I know, there aren't really any alternatives within tauri to produce the same result without this proposed solution. If there are any that I'm not thinking of, I'd love to hear and consider them.
Additional context
Nothing that I know of.
If I am incorrect in any assumptions here or not clear enough in any part of it, please let me know :) I would also be happy to submit a PR with the needed changes if this change is desired.
The text was updated successfully, but these errors were encountered: