Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change SetupHook from Box<dyn Fn(...)...> to Box<dyn FnOnce(...)...> #3061

Closed
itsjunetime opened this issue Dec 13, 2021 · 1 comment
Closed

Comments

@itsjunetime
Copy link

Is your feature request related to a problem? Please describe.
The SetupHook type utilizes Fn() instead of FnOnce(), even though it is only run once. This prevents users from moving values into the setup closure on tauri::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 to Box<dyn FnOnce(&mut App<R>) -> Result<(), Box<dyn std::error::Error + Send>> + Send>, and change the F generic parameter in tauri::Builder::setup to FnOnce(&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, since setup 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.

@JonasKruckenberg
Copy link
Contributor

JonasKruckenberg commented Dec 13, 2021

I like this, but last time I checked this brought a bunch of problems with it, because you can't wrap a FnOnce in a Fn.

Edit: If there's a way to make this work I'd love to know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants