Skip to content

Commit

Permalink
Wrap create_reducer dispatcher in Rc for ease of cloning
Browse files Browse the repository at this point in the history
  • Loading branch information
lukechu10 committed Sep 11, 2021
1 parent 73f09e8 commit 327fc54
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/sycamore-reactive/src/effect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ where
/// dispatch(Msg::Decrement);
/// assert_eq!(*state.get(), 0);
/// ```
pub fn create_reducer<F, Out, Msg>(initial: Out, reduce: F) -> (StateHandle<Out>, impl Fn(Msg))
pub fn create_reducer<F, Out, Msg>(initial: Out, reduce: F) -> (StateHandle<Out>, Rc<impl Fn(Msg)>)
where
F: Fn(&Out, Msg) -> Out,
{
Expand All @@ -416,7 +416,7 @@ where
}
};

(memo.into_handle(), dispatcher)
(memo.into_handle(), Rc::new(dispatcher))
}

/// Run the passed closure inside an untracked dependency scope.
Expand Down

0 comments on commit 327fc54

Please sign in to comment.