Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Component::change impl mandatory #1071

Merged
merged 1 commit into from Apr 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/macro/src/lib.rs
Expand Up @@ -31,6 +31,10 @@
//! # unimplemented!()
//! # }
//! #
//! # fn change(&mut self, props: Self::Properties) -> ShouldRender {
//! # unimplemented!()
//! # }
//! #
//! # fn view(&self) -> Html {
//! #
//! // ...
Expand Down
9 changes: 9 additions & 0 deletions crates/macro/tests/macro/html-component-fail.rs
Expand Up @@ -21,6 +21,9 @@ impl Component for Child {
fn update(&mut self, _: Self::Message) -> ShouldRender {
unimplemented!()
}
fn change(&mut self, _: Self::Properties) -> ShouldRender {
unimplemented!()
}
fn view(&self) -> Html {
unimplemented!()
}
Expand All @@ -42,6 +45,9 @@ impl Component for ChildContainer {
fn update(&mut self, _: Self::Message) -> ShouldRender {
unimplemented!()
}
fn change(&mut self, _: Self::Properties) -> ShouldRender {
unimplemented!()
}
fn view(&self) -> Html {
unimplemented!()
}
Expand All @@ -61,6 +67,9 @@ impl Component for Generic<String> {
fn update(&mut self, _: Self::Message) -> ShouldRender {
unimplemented!()
}
fn change(&mut self, _: Self::Properties) -> ShouldRender {
unimplemented!()
}
fn view(&self) -> Html {
unimplemented!()
}
Expand Down
256 changes: 128 additions & 128 deletions crates/macro/tests/macro/html-component-fail.stderr

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions crates/macro/tests/macro/html-component-pass.rs
Expand Up @@ -19,6 +19,9 @@ impl Component for Generic<String> {
fn update(&mut self, _: Self::Message) -> ShouldRender {
unimplemented!()
}
fn change(&mut self, _: Self::Properties) -> ShouldRender {
unimplemented!()
}
fn view(&self) -> Html {
unimplemented!()
}
Expand All @@ -34,6 +37,9 @@ impl Component for Generic<Vec<String>> {
fn update(&mut self, _: Self::Message) -> ShouldRender {
unimplemented!()
}
fn change(&mut self, _: Self::Properties) -> ShouldRender {
unimplemented!()
}
fn view(&self) -> Html {
unimplemented!()
}
Expand All @@ -57,6 +63,9 @@ impl Component for Container {
fn update(&mut self, _: Self::Message) -> ShouldRender {
unimplemented!()
}
fn change(&mut self, _: Self::Properties) -> ShouldRender {
unimplemented!()
}
fn view(&self) -> Html {
unimplemented!()
}
Expand Down Expand Up @@ -113,6 +122,9 @@ impl Component for Child {
fn update(&mut self, _: Self::Message) -> ShouldRender {
unimplemented!()
}
fn change(&mut self, _: Self::Properties) -> ShouldRender {
unimplemented!()
}
fn view(&self) -> Html {
unimplemented!()
}
Expand All @@ -129,6 +141,9 @@ impl Component for AltChild {
fn update(&mut self, _: Self::Message) -> ShouldRender {
unimplemented!()
}
fn change(&mut self, _: Self::Properties) -> ShouldRender {
unimplemented!()
}
fn view(&self) -> Html {
unimplemented!()
}
Expand All @@ -152,6 +167,9 @@ impl Component for ChildContainer {
fn update(&mut self, _: Self::Message) -> ShouldRender {
unimplemented!()
}
fn change(&mut self, _: Self::Properties) -> ShouldRender {
unimplemented!()
}
fn view(&self) -> Html {
unimplemented!()
}
Expand Down
4 changes: 4 additions & 0 deletions examples/crm/src/lib.rs
Expand Up @@ -146,6 +146,10 @@ impl Component for Model {
true
}

fn change(&mut self, _: Self::Properties) -> ShouldRender {
false
}

fn view(&self) -> Html {
match self.scene {
Scene::ClientsList => html! {
Expand Down
4 changes: 4 additions & 0 deletions examples/custom_components/src/lib.rs
Expand Up @@ -46,6 +46,10 @@ impl Component for Model {
}
}

fn change(&mut self, _: Self::Properties) -> ShouldRender {
false
}

fn view(&self) -> Html {
let counter = |x| {
html! {
Expand Down
4 changes: 4 additions & 0 deletions examples/dashboard/src/lib.rs
Expand Up @@ -186,6 +186,10 @@ impl Component for Model {
true
}

fn change(&mut self, _: Self::Properties) -> ShouldRender {
false
}

fn view(&self) -> Html {
html! {
<div>
Expand Down
4 changes: 4 additions & 0 deletions examples/fragments/src/lib.rs
Expand Up @@ -34,6 +34,10 @@ impl Component for Model {
true
}

fn change(&mut self, _: Self::Properties) -> ShouldRender {
false
}

fn view(&self) -> Html {
html! {
<>
Expand Down
4 changes: 4 additions & 0 deletions examples/game_of_life/src/lib.rs
Expand Up @@ -209,6 +209,10 @@ impl Component for Model {
true
}

fn change(&mut self, _: Self::Properties) -> ShouldRender {
false
}

fn view(&self) -> Html {
html! {
<div>
Expand Down
4 changes: 4 additions & 0 deletions examples/large_table/src/lib.rs
Expand Up @@ -33,6 +33,10 @@ impl Component for Model {
true
}

fn change(&mut self, _: Self::Properties) -> ShouldRender {
false
}

fn view(&self) -> Html {
html! {
<table>
Expand Down
4 changes: 4 additions & 0 deletions examples/showcase/src/main.rs
Expand Up @@ -91,6 +91,10 @@ impl Component for Model {
}
}

fn change(&mut self, _: Self::Properties) -> ShouldRender {
false
}

fn view(&self) -> Html {
html! {
<div id="fullscreen">
Expand Down
4 changes: 4 additions & 0 deletions examples/std_web/counter/src/lib.rs
Expand Up @@ -48,6 +48,10 @@ impl Component for Model {
true
}

fn change(&mut self, _: Self::Properties) -> ShouldRender {
false
}

fn view(&self) -> Html {
html! {
<div>
Expand Down
4 changes: 4 additions & 0 deletions examples/std_web/inner_html/src/lib.rs
Expand Up @@ -33,6 +33,10 @@ impl Component for Model {
true
}

fn change(&mut self, _: Self::Properties) -> ShouldRender {
false
}

fn view(&self) -> Html {
let js_svg = js! {
var div = document.createElement("div");
Expand Down
4 changes: 4 additions & 0 deletions examples/std_web/mount_point/src/lib.rs
Expand Up @@ -29,6 +29,10 @@ impl Component for Model {
true
}

fn change(&mut self, _: Self::Properties) -> ShouldRender {
false
}

fn view(&self) -> Html {
html! {
<div>
Expand Down
5 changes: 5 additions & 0 deletions examples/std_web/node_refs/src/input.rs
Expand Up @@ -31,6 +31,11 @@ impl Component for InputComponent {
false
}

fn change(&mut self, props: Self::Properties) -> ShouldRender {
self.props = props;
true
}

fn view(&self) -> Html {
html! {
<input
Expand Down
4 changes: 4 additions & 0 deletions examples/std_web/node_refs/src/lib.rs
Expand Up @@ -46,6 +46,10 @@ impl Component for Model {
true
}

fn change(&mut self, _: Self::Properties) -> ShouldRender {
false
}

fn view(&self) -> Html {
html! {
<div class="main">
Expand Down
4 changes: 4 additions & 0 deletions examples/std_web/npm_and_rest/src/lib.rs
Expand Up @@ -67,6 +67,10 @@ impl Component for Model {
true
}

fn change(&mut self, _: Self::Properties) -> ShouldRender {
false
}

fn view(&self) -> Html {
let view_exchange = |exchange| {
html! {
Expand Down
4 changes: 4 additions & 0 deletions examples/std_web/todomvc/src/lib.rs
Expand Up @@ -121,6 +121,10 @@ impl Component for Model {
true
}

fn change(&mut self, _: Self::Properties) -> ShouldRender {
false
}

fn view(&self) -> Html {
html! {
<div class="todomvc-wrapper">
Expand Down
4 changes: 4 additions & 0 deletions examples/std_web/two_apps/src/lib.rs
Expand Up @@ -57,6 +57,10 @@ impl Component for Model {
true
}

fn change(&mut self, _: Self::Properties) -> ShouldRender {
false
}

fn view(&self) -> Html {
html! {
<div>
Expand Down
4 changes: 4 additions & 0 deletions examples/textarea/src/lib.rs
Expand Up @@ -35,6 +35,10 @@ impl Component for Model {
true
}

fn change(&mut self, _: Self::Properties) -> ShouldRender {
false
}

fn view(&self) -> Html {
html! {
<div>
Expand Down
4 changes: 4 additions & 0 deletions examples/timer/src/lib.rs
Expand Up @@ -97,6 +97,10 @@ impl Component for Model {
true
}

fn change(&mut self, _: Self::Properties) -> ShouldRender {
false
}

fn view(&self) -> Html {
let view_message = |message| {
html! { <p>{ message }</p> }
Expand Down
4 changes: 4 additions & 0 deletions examples/web_sys/counter/src/lib.rs
Expand Up @@ -48,6 +48,10 @@ impl Component for Model {
true
}

fn change(&mut self, _: Self::Properties) -> ShouldRender {
false
}

fn view(&self) -> Html {
html! {
<div>
Expand Down
4 changes: 4 additions & 0 deletions examples/web_sys/inner_html/src/lib.rs
Expand Up @@ -30,6 +30,10 @@ impl Component for Model {
true
}

fn change(&mut self, _: Self::Properties) -> ShouldRender {
false
}

fn view(&self) -> Html {
let js_svg = {
let div = web_sys::window()
Expand Down
4 changes: 4 additions & 0 deletions examples/web_sys/mount_point/src/lib.rs
Expand Up @@ -29,6 +29,10 @@ impl Component for Model {
true
}

fn change(&mut self, _: Self::Properties) -> ShouldRender {
false
}

fn view(&self) -> Html {
html! {
<div>
Expand Down
5 changes: 5 additions & 0 deletions examples/web_sys/node_refs/src/input.rs
Expand Up @@ -31,6 +31,11 @@ impl Component for InputComponent {
false
}

fn change(&mut self, props: Self::Properties) -> ShouldRender {
self.props = props;
true
}

fn view(&self) -> Html {
html! {
<input
Expand Down
4 changes: 4 additions & 0 deletions examples/web_sys/node_refs/src/lib.rs
Expand Up @@ -45,6 +45,10 @@ impl Component for Model {
true
}

fn change(&mut self, _: Self::Properties) -> ShouldRender {
false
}

fn view(&self) -> Html {
html! {
<div class="main">
Expand Down
4 changes: 4 additions & 0 deletions examples/web_sys/npm_and_rest/src/lib.rs
Expand Up @@ -64,6 +64,10 @@ impl Component for Model {
true
}

fn change(&mut self, _: Self::Properties) -> ShouldRender {
false
}

fn view(&self) -> Html {
let view_exchange = |exchange| {
html! {
Expand Down
4 changes: 4 additions & 0 deletions examples/web_sys/todomvc/src/lib.rs
Expand Up @@ -121,6 +121,10 @@ impl Component for Model {
true
}

fn change(&mut self, _: Self::Properties) -> ShouldRender {
false
}

fn view(&self) -> Html {
html! {
<div class="todomvc-wrapper">
Expand Down
4 changes: 4 additions & 0 deletions examples/web_sys/two_apps/src/lib.rs
Expand Up @@ -57,6 +57,10 @@ impl Component for Model {
true
}

fn change(&mut self, _: Self::Properties) -> ShouldRender {
false
}

fn view(&self) -> Html {
html! {
<div>
Expand Down
1 change: 1 addition & 0 deletions src/components/select.rs
Expand Up @@ -14,6 +14,7 @@
//!# type Message = ();type Properties = ();
//!# fn create(props: Self::Properties,link: ComponentLink<Self>) -> Self {unimplemented!()}
//!# fn update(&mut self,msg: Self::Message) -> bool {unimplemented!()}
//!# fn change(&mut self, _: Self::Properties) -> bool {unimplemented!()}
//!# fn view(&self) -> Html {unimplemented!()}}
//! impl ToString for Scene {
//! fn to_string(&self) -> String {
Expand Down