drop Sync req from setup and setup_with_config (#3471)

This commit is contained in:
Jonas Kruckenberg
2022-02-16 14:06:56 +01:00
committed by GitHub
parent 123beddc52
commit fb7ee2c987
2 changed files with 9 additions and 4 deletions

View File

@@ -0,0 +1,5 @@
---
"tauri": patch
---
Callbacks passed to `tauri::plugin::Builder::setup` or `tauri::plugin::Builder::setup_with_config` are no longer required to implement `Sync`.

View File

@@ -54,8 +54,8 @@ pub trait Plugin<R: Runtime>: Send {
fn extend_api(&mut self, invoke: Invoke<R>) {}
}
type SetupHook<R> = dyn FnOnce(&AppHandle<R>) -> Result<()> + Send + Sync;
type SetupWithConfigHook<R, T> = dyn FnOnce(&AppHandle<R>, T) -> Result<()> + Send + Sync;
type SetupHook<R> = dyn FnOnce(&AppHandle<R>) -> Result<()> + Send;
type SetupWithConfigHook<R, T> = dyn FnOnce(&AppHandle<R>, T) -> Result<()> + Send;
type OnWebviewReady<R> = dyn FnMut(Window<R>) + Send + Sync;
type OnEvent<R> = dyn FnMut(&AppHandle<R>, &RunEvent) + Send + Sync;
type OnPageLoad<R> = dyn FnMut(Window<R>, PageLoadPayload) + Send + Sync;
@@ -251,7 +251,7 @@ impl<R: Runtime, C: DeserializeOwned> Builder<R, C> {
#[must_use]
pub fn setup<F>(mut self, setup: F) -> Self
where
F: FnOnce(&AppHandle<R>) -> Result<()> + Send + Sync + 'static,
F: FnOnce(&AppHandle<R>) -> Result<()> + Send + 'static,
{
self.setup.replace(Box::new(setup));
self
@@ -287,7 +287,7 @@ impl<R: Runtime, C: DeserializeOwned> Builder<R, C> {
#[must_use]
pub fn setup_with_config<F>(mut self, setup_with_config: F) -> Self
where
F: FnOnce(&AppHandle<R>, C) -> Result<()> + Send + Sync + 'static,
F: FnOnce(&AppHandle<R>, C) -> Result<()> + Send + 'static,
{
self.setup_with_config.replace(Box::new(setup_with_config));
self