Skip to content

Commit

Permalink
Change callback reform to not consume self (yewstack#779)
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry authored and llebout committed Jan 20, 2020
1 parent fd1ebd6 commit 42f2e00
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ impl<IN> Callback<IN> {
impl<IN: 'static> Callback<IN> {
/// Changes input type of the callback to another.
/// Works like common `map` method but in an opposite direction.
pub fn reform<F, T>(self, func: F) -> Callback<T>
pub fn reform<F, T>(&self, func: F) -> Callback<T>
where
F: Fn(T) -> IN + 'static,
{
let this = self.clone();
let func = move |input| {
let output = func(input);
self.clone().emit(output);
this.emit(output);
};
Callback::from(func)
}
Expand Down

0 comments on commit 42f2e00

Please sign in to comment.