Skip to content

Commit 22eacc2

Browse files
author
mc1098
committed
Remove ShouldRender type alias
Remove `ShouldRender` type alias for bool. In the Component trait an extra comment has been added to explain what the returned bool represents.
1 parent f50c8c3 commit 22eacc2

File tree

46 files changed

+82
-87
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+82
-87
lines changed

examples/boids/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use settings::Settings;
22
use simulation::Simulation;
33
use slider::Slider;
44
use yew::html::Scope;
5-
use yew::{html, Component, Context, Html, ShouldRender};
5+
use yew::{html, Component, Context, Html};
66

77
mod boid;
88
mod math;
@@ -34,7 +34,7 @@ impl Component for Model {
3434
}
3535
}
3636

37-
fn update(&mut self, _ctx: &Context<Self>, msg: Msg) -> ShouldRender {
37+
fn update(&mut self, _ctx: &Context<Self>, msg: Msg) -> bool {
3838
match msg {
3939
Msg::ChangeSettings(settings) => {
4040
self.settings = settings;

examples/boids/src/simulation.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::boid::Boid;
22
use crate::math::Vector2D;
33
use crate::settings::Settings;
44
use gloo::timers::callback::Interval;
5-
use yew::{html, Component, Context, Html, Properties, ShouldRender};
5+
use yew::{html, Component, Context, Html, Properties};
66

77
pub const SIZE: Vector2D = Vector2D::new(1600.0, 1000.0);
88

@@ -45,7 +45,7 @@ impl Component for Simulation {
4545
Self { boids, interval }
4646
}
4747

48-
fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> ShouldRender {
48+
fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool {
4949
match msg {
5050
Msg::Tick => {
5151
let Props {
@@ -64,7 +64,7 @@ impl Component for Simulation {
6464
}
6565
}
6666

67-
fn changed(&mut self, ctx: &Context<Self>) -> ShouldRender {
67+
fn changed(&mut self, ctx: &Context<Self>) -> bool {
6868
self.boids.clear();
6969

7070
let settings = &ctx.props().settings;

examples/boids/src/slider.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::cell::Cell;
22
use yew::{
33
html, web_sys::HtmlInputElement, Callback, Component, Context, Html, InputEvent, Properties,
4-
ShouldRender, TargetCast,
4+
TargetCast,
55
};
66

77
thread_local! {
@@ -40,7 +40,7 @@ impl Component for Slider {
4040
}
4141
}
4242

43-
fn update(&mut self, _ctx: &Context<Self>, _msg: Self::Message) -> ShouldRender {
43+
fn update(&mut self, _ctx: &Context<Self>, _msg: Self::Message) -> bool {
4444
unimplemented!()
4545
}
4646

examples/counter/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use js_sys::Date;
22
use weblog::console_log;
3-
use yew::{html, Component, Context, Html, ShouldRender};
3+
use yew::{html, Component, Context, Html};
44

55
// Define the possible messages which can be sent to the component
66
pub enum Msg {
@@ -20,7 +20,7 @@ impl Component for Model {
2020
Self { value: 0 }
2121
}
2222

23-
fn update(&mut self, _ctx: &Context<Self>, msg: Self::Message) -> ShouldRender {
23+
fn update(&mut self, _ctx: &Context<Self>, msg: Self::Message) -> bool {
2424
match msg {
2525
Msg::Increment => {
2626
self.value += 1;

examples/crm/src/add_client.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use crate::Client;
22
use yew::web_sys::{Event, HtmlInputElement, HtmlTextAreaElement};
3-
use yew::{
4-
classes, html, Callback, Component, Context, Html, Properties, ShouldRender, TargetCast,
5-
};
3+
use yew::{classes, html, Callback, Component, Context, Html, Properties, TargetCast};
64

75
#[derive(Debug)]
86
pub enum Msg {
@@ -32,7 +30,7 @@ impl Component for AddClientForm {
3230
}
3331
}
3432

35-
fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> ShouldRender {
33+
fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool {
3634
let client = &mut self.client;
3735
match msg {
3836
Msg::UpdateFirstName(value) => {

examples/crm/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use add_client::AddClientForm;
22
use gloo::storage::{LocalStorage, Storage};
33
use serde::{Deserialize, Serialize};
4-
use yew::{html, Component, Context, Html, ShouldRender};
4+
use yew::{html, Component, Context, Html};
55

66
mod add_client;
77

@@ -59,7 +59,7 @@ impl Component for Model {
5959
}
6060
}
6161

62-
fn update(&mut self, _ctx: &Context<Self>, msg: Self::Message) -> ShouldRender {
62+
fn update(&mut self, _ctx: &Context<Self>, msg: Self::Message) -> bool {
6363
match msg {
6464
Msg::SwitchTo(scene) => {
6565
self.scene = scene;

examples/dyn_create_destroy_apps/src/counter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl Component for CounterModel {
3030
}
3131
}
3232

33-
fn update(&mut self, _ctx: &Context<Self>, msg: Self::Message) -> ShouldRender {
33+
fn update(&mut self, _ctx: &Context<Self>, msg: Self::Message) -> bool {
3434
match msg {
3535
// Count our internal state up by one
3636
Self::Message::Tick => {

examples/dyn_create_destroy_apps/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl Component for Model {
3131
}
3232
}
3333

34-
fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> ShouldRender {
34+
fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool {
3535
let app_container = self
3636
.apps_container_ref
3737
.cast::<Element>()

examples/file_upload/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use web_sys::{Event, HtmlInputElement};
2-
use yew::{html, html::TargetCast, Component, Context, Html, ShouldRender};
2+
use yew::{html, html::TargetCast, Component, Context, Html};
33

44
use gloo::file::callbacks::FileReader;
55
use gloo::file::File;
@@ -31,7 +31,7 @@ impl Component for Model {
3131
}
3232
}
3333

34-
fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> ShouldRender {
34+
fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool {
3535
match msg {
3636
Msg::Loaded(file_name, data) => {
3737
let info = format!("file_name: {}, data: {:?}", file_name, data);

examples/futures/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use wasm_bindgen::prelude::*;
66
use wasm_bindgen::JsCast;
77
use wasm_bindgen_futures::JsFuture;
88
use web_sys::{Request, RequestInit, RequestMode, Response};
9-
use yew::{html, Component, Context, Html, ShouldRender};
9+
use yew::{html, Component, Context, Html};
1010

1111
mod markdown;
1212

@@ -77,7 +77,7 @@ impl Component for Model {
7777
}
7878
}
7979

80-
fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> ShouldRender {
80+
fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool {
8181
match msg {
8282
Msg::SetMarkdownFetchState(fetch_state) => {
8383
self.markdown = fetch_state;

0 commit comments

Comments
 (0)