Skip to content

Commit

Permalink
Merge #367
Browse files Browse the repository at this point in the history
367: Require mutable reference for send_back method call r=DenisKolodin a=DenisKolodin

This PR is separated from #365 to buy time to make backward incompatible changes.

Co-authored-by: Denis Kolodin <deniskolodin@gmail.com>
  • Loading branch information
bors[bot] and therustmonk committed Aug 27, 2018
2 parents 7e921ff + 07573eb commit eda8353
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
All examples had changed.

- `html!` macro adds `move` modifier and the type of event for every handler (#240). Use
`<input oninput=|e| Msg::UpdateEvent(e.value), />` instead of obsolete
`<input oninput=move |e: InputData| Msg::UpdateEvent(e.value), />`.
`<input oninput=|e| Msg::UpdateEvent(e.value), />` instead of obsolete
`<input oninput=move |e: InputData| Msg::UpdateEvent(e.value), />`.

- `send_back` method requires a mutable reference to `self`. This was added to prevent creating
callbacks in `view` implementations.

### New features

Expand Down
2 changes: 1 addition & 1 deletion examples/game_of_life/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl Component for Model {
type Message = Msg;
type Properties = ();

fn create(_: Self::Properties, link: ComponentLink<Self>) -> Self {
fn create(_: Self::Properties, mut link: ComponentLink<Self>) -> Self {
let callback = link.send_back(|_| Msg::Tick);
let mut interval = IntervalService::new();
let handle = interval.spawn(Duration::from_millis(200), callback);
Expand Down
2 changes: 1 addition & 1 deletion examples/npm_and_rest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl Component for Model {
type Message = Msg;
type Properties = ();

fn create(_: Self::Properties, link: ComponentLink<Self>) -> Self {
fn create(_: Self::Properties, mut link: ComponentLink<Self>) -> Self {
Model {
gravatar: GravatarService::new(),
ccxt: CcxtService::new(),
Expand Down
2 changes: 1 addition & 1 deletion examples/timer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Component for Model {
type Message = Msg;
type Properties = ();

fn create(_: Self::Properties, link: ComponentLink<Self>) -> Self {
fn create(_: Self::Properties, mut link: ComponentLink<Self>) -> Self {
// This callback doesn't send any message to a scope
let callback = |_| {
println!("Example of a standalone callback.");
Expand Down
2 changes: 1 addition & 1 deletion src/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ where
}

/// This method sends messages back to the component's loop.
pub fn send_back<F, IN>(&self, function: F) -> Callback<IN>
pub fn send_back<F, IN>(&mut self, function: F) -> Callback<IN>
where
F: Fn(IN) -> COMP::Message + 'static,
{
Expand Down

0 comments on commit eda8353

Please sign in to comment.