Skip to content

Commit

Permalink
drop Sync req from setup and setup_with_config (#3471)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasKruckenberg authored Feb 16, 2022
1 parent 123bedd commit fb7ee2c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-drop-sync.md
Original file line number Diff line number Diff line change
@@ -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`.
8 changes: 4 additions & 4 deletions core/tauri/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fb7ee2c

Please sign in to comment.