From fddc7c6883c38e10ab515f1e094995357ea3ef01 Mon Sep 17 00:00:00 2001 From: Thomas Lacroix Date: Sun, 1 Mar 2020 21:42:22 +0100 Subject: [PATCH] Fix pub_sub example that no longer compiles in 0.13 --- examples/pub_sub/Cargo.toml | 2 +- examples/pub_sub/src/event_bus.rs | 1 - examples/pub_sub/src/lib.rs | 4 ++-- examples/pub_sub/src/producer.rs | 2 +- examples/pub_sub/src/subscriber.rs | 10 +++++----- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/examples/pub_sub/Cargo.toml b/examples/pub_sub/Cargo.toml index ae252d2c357..058ebd133e2 100644 --- a/examples/pub_sub/Cargo.toml +++ b/examples/pub_sub/Cargo.toml @@ -7,5 +7,5 @@ edition = "2018" log = "0.4" web_logger = "0.1" serde = { version = "1.0", features = ["derive"] } -yew = { path = "../.." } +yew = { path = "../..", features = ["std_web"] } stdweb = "0.4.20" diff --git a/examples/pub_sub/src/event_bus.rs b/examples/pub_sub/src/event_bus.rs index 3d4fffc812b..977793f86f9 100644 --- a/examples/pub_sub/src/event_bus.rs +++ b/examples/pub_sub/src/event_bus.rs @@ -1,6 +1,5 @@ use serde::{Deserialize, Serialize}; use std::collections::HashSet; -use std::fmt::Debug; use yew::worker::*; #[derive(Serialize, Deserialize, Debug)] diff --git a/examples/pub_sub/src/lib.rs b/examples/pub_sub/src/lib.rs index 83aa59a6544..548c2f0495a 100644 --- a/examples/pub_sub/src/lib.rs +++ b/examples/pub_sub/src/lib.rs @@ -5,7 +5,7 @@ mod producer; mod subscriber; use producer::Producer; -use subscriber::Subsciber; +use subscriber::Subscriber; use yew::{html, Component, ComponentLink, Html, ShouldRender}; pub struct Model {} @@ -26,7 +26,7 @@ impl Component for Model { html! {
- +
} } diff --git a/examples/pub_sub/src/producer.rs b/examples/pub_sub/src/producer.rs index ce2a30de87a..3c08e6bdd5c 100644 --- a/examples/pub_sub/src/producer.rs +++ b/examples/pub_sub/src/producer.rs @@ -28,7 +28,7 @@ impl Component for Producer { match msg { Msg::Clicked => { self.event_bus - .send(Request::EventBusMsg(format!("Message receieved"))); + .send(Request::EventBusMsg(format!("Message received"))); false } } diff --git a/examples/pub_sub/src/subscriber.rs b/examples/pub_sub/src/subscriber.rs index 44eae38e278..00a4e1d66c1 100644 --- a/examples/pub_sub/src/subscriber.rs +++ b/examples/pub_sub/src/subscriber.rs @@ -6,20 +6,20 @@ pub enum Msg { NewMessage(String), } -pub struct Subsciber { +pub struct Subscriber { message: String, _producer: Box>, } -impl Component for Subsciber { +impl Component for Subscriber { type Message = Msg; type Properties = (); fn create(_: Self::Properties, link: ComponentLink) -> Self { let callback = link.callback(|s| Msg::NewMessage(s)); let _producer = EventBus::bridge(callback); - Subsciber { - message: format!("No message yet"), + Subscriber { + message: format!("No message yet."), _producer, } } @@ -33,7 +33,7 @@ impl Component for Subsciber { fn view(&self) -> Html { html! { -

{self.message.clone()}

+

{ &self.message }

} } }