Skip to content

Commit

Permalink
pass window to ctx fn by ref (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendonovich committed Sep 17, 2023
1 parent 988878c commit ec02628
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/integrations/tauri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct Msg(serde_json::Value);
struct WindowManager<TCtxFn, TCtx>
where
TCtx: Send + Sync + 'static,
TCtxFn: Fn(Window<tauri::Wry>) -> TCtx + Send + Sync + 'static,
TCtxFn: Fn(&Window<tauri::Wry>) -> TCtx + Send + Sync + 'static,
{
executor: Executor<TCtx>,
ctx_fn: TCtxFn,
Expand All @@ -39,7 +39,7 @@ where
impl<TCtxFn, TCtx> WindowManager<TCtxFn, TCtx>
where
TCtx: Clone + Send + Sync + 'static,
TCtxFn: Fn(Window<tauri::Wry>) -> TCtx + Send + Sync + 'static,
TCtxFn: Fn(&Window<tauri::Wry>) -> TCtx + Send + Sync + 'static,
{
pub fn new(ctx_fn: TCtxFn, router: Arc<BuiltRouter<TCtx>>) -> Arc<Self> {
Arc::new(Self {
Expand Down Expand Up @@ -68,7 +68,7 @@ where

let (tx, rx) = mpsc::unbounded_channel();
R::spawn(ConnectionTask::<R, _, _, _>::new(
(self.ctx_fn)(window.clone()),
(self.ctx_fn)(&window),
self.executor.clone(),
Socket {
recv: rx,
Expand Down Expand Up @@ -119,7 +119,7 @@ mod test {

pub fn plugin<TCtx>(
router: Arc<BuiltRouter<TCtx>>,
ctx_fn: impl Fn(Window<tauri::Wry>) -> TCtx + Send + Sync + 'static,
ctx_fn: impl Fn(&Window<tauri::Wry>) -> TCtx + Send + Sync + 'static,
) -> TauriPlugin<tauri::Wry>
where
TCtx: Clone + Send + Sync + 'static,
Expand Down

0 comments on commit ec02628

Please sign in to comment.