From 0721ea0a712299e5d4a8e4683748de4794d91c15 Mon Sep 17 00:00:00 2001 From: Jovansonlee Cesar Date: Mon, 1 Apr 2024 23:00:15 +0800 Subject: [PATCH] refactor: **breaking** reclaim back Cmd which is now the name for Task/Sub/Action --- crates/core/src/dom.rs | 4 +- crates/core/src/dom/application.rs | 12 +++--- crates/core/src/dom/{task.rs => cmd.rs} | 37 ++++++++++++++---- .../src/dom/component/stateful_component.rs | 2 +- crates/core/src/dom/dispatch.rs | 6 +-- crates/core/src/dom/dom_patch.rs | 1 - crates/core/src/dom/effects.rs | 32 +++++++-------- crates/core/src/dom/program.rs | 3 ++ crates/core/src/dom/window.rs | 28 ++++++------- crates/core/src/lib.rs | 2 +- examples/fetch-data-component/README.md | 2 + examples/fetch-data-component/src/fetcher.rs | 13 +++++-- examples/fetch-data-component/src/lib.rs | 4 +- examples/fetch-data-macro-syntax/Cargo.toml | 3 +- examples/fetch-data-macro-syntax/src/lib.rs | 39 +++++++++++++------ examples/fetch-data/src/lib.rs | 18 ++++----- examples/interactive-macro-syntax/src/app.rs | 6 +-- examples/resize/src/lib.rs | 10 ++--- 18 files changed, 134 insertions(+), 88 deletions(-) rename crates/core/src/dom/{task.rs => cmd.rs} (86%) diff --git a/crates/core/src/dom.rs b/crates/core/src/dom.rs index 4b06fa651..9043936b5 100644 --- a/crates/core/src/dom.rs +++ b/crates/core/src/dom.rs @@ -4,12 +4,12 @@ pub use component::Component; pub use effects::Effects; pub use modifier::Modifier; -pub use task::Task; +pub use cmd::Cmd; mod component; mod effects; mod modifier; -mod task; +mod cmd; use cfg_if::cfg_if; diff --git a/crates/core/src/dom/application.rs b/crates/core/src/dom/application.rs index 4e8726e24..15acbe1e4 100644 --- a/crates/core/src/dom/application.rs +++ b/crates/core/src/dom/application.rs @@ -1,6 +1,6 @@ use crate::vdom::Node; pub use skip_diff::{skip_if, SkipDiff, SkipPath}; -use crate::dom::Task; +use crate::dom::Cmd; /// pub mod skip_diff; @@ -13,15 +13,15 @@ pub trait Application: Sized + 'static { type MSG; /// The application can implement this method where it can modify its initial state. /// This method is called right after the program is mounted into the DOM. - fn init(&mut self) -> Task { - Task::none() + fn init(&mut self) -> Cmd { + Cmd::none() } /// Update the component with a message. /// The update function returns a Dispatch, which can be executed by the runtime. /// /// Called each time an action is triggered from the view - fn update(&mut self, _msg: Self::MSG) -> Task; + fn update(&mut self, _msg: Self::MSG) -> Cmd; /// Returns a node on how the component is presented. fn view(&self) -> Node; @@ -40,9 +40,9 @@ pub trait Application: Sized + 'static { /// This is for diagnostic and performance measurement purposes. /// /// Warning: DO NOT use for anything else other than the intended purpose - fn measurements(&self, measurements: Measurements) -> Task { + fn measurements(&self, measurements: Measurements) -> Cmd { log::debug!("Measurements: {:#?}", measurements); - Task::none().no_render() + Cmd::none().no_render() } } diff --git a/crates/core/src/dom/task.rs b/crates/core/src/dom/cmd.rs similarity index 86% rename from crates/core/src/dom/task.rs rename to crates/core/src/dom/cmd.rs index 64f5d495e..a7e3c7f10 100644 --- a/crates/core/src/dom/task.rs +++ b/crates/core/src/dom/cmd.rs @@ -17,13 +17,13 @@ pub enum Command { } /// -pub struct Task{ +pub struct Cmd{ /// commands pub(crate) commands: Vec>, pub(crate) modifier: Modifier, } -impl Task +impl Cmd where MSG: 'static, { @@ -45,19 +45,19 @@ where } } - /// map the msg of this Task such that Task becomes Task. - pub fn map_msg(self, f: F) -> Task + /// map the msg of this Cmd such that Cmd becomes Cmd. + pub fn map_msg(self, f: F) -> Cmd where F: Fn(MSG) -> MSG2 + 'static + Clone, MSG2: 'static, { - Task{ + Cmd{ commands: self.commands.into_iter().map(|t|t.map_msg(f.clone())).collect(), modifier: Default::default(), } } - /// batch together multiple Task into one task + /// batch together multiple Cmd into one task pub fn batch(tasks: impl IntoIterator) -> Self { let mut commands = vec![]; for task in tasks.into_iter(){ @@ -83,7 +83,8 @@ where } -impl From> for Task +/* +impl From> for Cmd where MSG: 'static { /// Convert Effects that has only follow ups @@ -96,7 +97,27 @@ impl From> for Task modifier:_, } = effects; - Task::batch(local.into_iter().chain(external.into_iter()).map(Task::from)) + Cmd::batch(local.into_iter().chain(external.into_iter()).map(Cmd::from)) + } +} +*/ + +impl From> for Cmd + where MSG: 'static +{ + /// Convert Effects that has only follow ups + fn from(effects: Effects) -> Self { + // we can safely ignore the effects here + // as there is no content on it. + let Effects { + local, + external:_, + modifier, + } = effects; + + let mut cmd = Cmd::batch(local.into_iter().map(Cmd::from)); + cmd.modifier = modifier; + cmd } } diff --git a/crates/core/src/dom/component/stateful_component.rs b/crates/core/src/dom/component/stateful_component.rs index 09cb4085e..75bf16f1d 100644 --- a/crates/core/src/dom/component/stateful_component.rs +++ b/crates/core/src/dom/component/stateful_component.rs @@ -2,7 +2,7 @@ use crate::dom::events::on_mount; use crate::dom::program::MountProcedure; use crate::dom::Application; -use crate::dom::Task; +use crate::dom::Cmd; use crate::dom::Component; use crate::dom::DomAttrValue; use crate::dom::DomNode; diff --git a/crates/core/src/dom/dispatch.rs b/crates/core/src/dom/dispatch.rs index 27f781eb5..c07563ae0 100644 --- a/crates/core/src/dom/dispatch.rs +++ b/crates/core/src/dom/dispatch.rs @@ -2,7 +2,7 @@ //! when the application starts or after the application updates. //! use crate::dom::Program; -use crate::dom::{Application, Effects, Modifier, Task}; +use crate::dom::{Application, Effects, Modifier, Cmd}; use wasm_bindgen_futures::spawn_local; /// Dispatch is a command to be executed by the system. @@ -150,11 +150,11 @@ where } } -impl From> for Dispatch +impl From> for Dispatch where APP: Application, { - fn from(task: Task) -> Self { + fn from(task: Cmd) -> Self { Dispatch::new(move |program| { for mut command in task.commands.into_iter(){ let program = program.downgrade(); diff --git a/crates/core/src/dom/dom_patch.rs b/crates/core/src/dom/dom_patch.rs index dda8ccfc6..6c3cd22d4 100644 --- a/crates/core/src/dom/dom_patch.rs +++ b/crates/core/src/dom/dom_patch.rs @@ -394,7 +394,6 @@ where first_node.insert_after(replacement); } if patch_path.path.is_empty() { - log::info!("setting root node to the first node at non-fragment"); *self.root_node.borrow_mut() = Some(first_node); } } diff --git a/crates/core/src/dom/effects.rs b/crates/core/src/dom/effects.rs index d59f9e63b..49be5769f 100644 --- a/crates/core/src/dom/effects.rs +++ b/crates/core/src/dom/effects.rs @@ -1,5 +1,5 @@ use crate::dom::Modifier; -use crate::dom::Task; +use crate::dom::Cmd; use std::future::ready; use std::future::Future; @@ -12,10 +12,10 @@ use std::future::Future; /// that are sent to the parent Component in response to an event that has been triggerred. pub struct Effects { /// Messages that will be executed locally in the Component - pub local: Vec>, + pub local: Vec>, /// effects that will be executed on the parent Component which instantiate /// this component - pub external: Vec>, + pub external: Vec>, pub(crate) modifier: Modifier, } @@ -32,10 +32,10 @@ where XMSG: 'static, { Self { - local: local.into_iter().map(|l| Task::single(ready(l))).collect(), + local: local.into_iter().map(|l| Cmd::single(ready(l))).collect(), external: external .into_iter() - .map(|x| Task::single(ready(x))) + .map(|x| Cmd::single(ready(x))) .collect(), modifier: Modifier::default(), } @@ -53,8 +53,8 @@ where XMSG: 'static, { Self { - local: local.into_iter().map(Task::single).collect(), - external: external.into_iter().map(Task::single).collect(), + local: local.into_iter().map(Cmd::single).collect(), + external: external.into_iter().map(Cmd::single).collect(), modifier: Modifier::default(), } } @@ -62,7 +62,7 @@ where /// Create an Effects with local messages that will be executed on the next update loop on this Component pub fn with_local(local: impl IntoIterator) -> Self { Self { - local: local.into_iter().map(|l| Task::single(ready(l))).collect(), + local: local.into_iter().map(|l| Cmd::single(ready(l))).collect(), external: vec![], modifier: Modifier::default(), } @@ -75,7 +75,7 @@ where F: Future + 'static, { Self { - local: local.into_iter().map(Task::single).collect(), + local: local.into_iter().map(Cmd::single).collect(), external: vec![], modifier: Modifier::default(), } @@ -90,7 +90,7 @@ where local: vec![], external: external .into_iter() - .map(|x| Task::single(ready(x))) + .map(|x| Cmd::single(ready(x))) .collect(), modifier: Modifier::default(), } @@ -105,7 +105,7 @@ where { Self { local: vec![], - external: external.into_iter().map(Task::single).collect(), + external: external.into_iter().map(Cmd::single).collect(), modifier: Modifier::default(), } } @@ -189,7 +189,7 @@ where /// Append this msgs to the local effects pub fn append_local(mut self, local: impl IntoIterator) -> Self { self.local - .extend(local.into_iter().map(|l| Task::single(ready(l)))); + .extend(local.into_iter().map(|l| Cmd::single(ready(l)))); self } @@ -238,15 +238,15 @@ where XMSG: 'static, { self.local - .extend(local.into_iter().map(|l| Task::single(ready(l)))); + .extend(local.into_iter().map(|l| Cmd::single(ready(l)))); self.external - .extend(external.into_iter().map(|x| Task::single(ready(x)))); + .extend(external.into_iter().map(|x| Cmd::single(ready(x)))); self } } -impl From> for Effects { - fn from(task: Task) -> Effects { +impl From> for Effects { + fn from(task: Cmd) -> Effects { Effects { local: vec![task], external: vec![], diff --git a/crates/core/src/dom/program.rs b/crates/core/src/dom/program.rs index f52fda863..cabcb4b90 100644 --- a/crates/core/src/dom/program.rs +++ b/crates/core/src/dom/program.rs @@ -435,6 +435,7 @@ where /// execute DOM changes in order to reflect the APP's view into the browser representation pub fn update_dom(&mut self, modifier: &Modifier) -> Result<(), JsValue> { + log::info!("updating the dom..."); let t1 = now(); // a new view is created due to the app update let view = self.app_context.view(); @@ -684,6 +685,8 @@ where if cmd.modifier.should_update_view { self.update_dom(&cmd.modifier).expect("must update dom"); + }else{ + log::warn!("not updating dom..."); } // Ensure all pending patches are applied before emiting the Cmd from update diff --git a/crates/core/src/dom/window.rs b/crates/core/src/dom/window.rs index 20c0a5677..0be16a41d 100644 --- a/crates/core/src/dom/window.rs +++ b/crates/core/src/dom/window.rs @@ -1,4 +1,4 @@ -use crate::dom::{dom_node::intern, util, window, Task}; +use crate::dom::{dom_node::intern, util, window, Cmd}; use futures::channel::mpsc; use wasm_bindgen::{prelude::*, JsCast}; use web_sys::MouseEvent; @@ -8,9 +8,9 @@ use web_sys::MouseEvent; pub struct Window; impl Window { - /// Create a recurring Task which will be triggered + /// Create a recurring Cmd which will be triggered /// everytime the window is resized - pub fn on_resize(mut cb: F) -> Task + pub fn on_resize(mut cb: F) -> Cmd where F: FnMut(i32, i32) -> MSG + Clone + 'static, MSG: 'static, @@ -30,11 +30,11 @@ impl Window { ) .expect("add event callback"); - Task::sub(rx, resize_callback) + Cmd::sub(rx, resize_callback) } /// - pub fn on_mousemove(mut cb: F) -> Task + pub fn on_mousemove(mut cb: F) -> Cmd where F: FnMut(web_sys::MouseEvent) -> MSG + Clone + 'static, MSG: 'static, @@ -52,11 +52,11 @@ impl Window { mousemove_cb.as_ref().unchecked_ref(), ) .expect("add event callback"); - Task::sub(rx, mousemove_cb) + Cmd::sub(rx, mousemove_cb) } /// - pub fn on_mouseup(mut cb: F) -> Task + pub fn on_mouseup(mut cb: F) -> Cmd where F: FnMut(web_sys::MouseEvent) -> MSG + Clone + 'static, MSG: 'static, @@ -74,11 +74,11 @@ impl Window { mousemove_cb.as_ref().unchecked_ref(), ) .expect("add event callback"); - Task::sub(rx, mousemove_cb) + Cmd::sub(rx, mousemove_cb) } /// do this task at every `ms` interval - pub fn every_interval(interval_ms: i32, cb: F) -> Task + pub fn every_interval(interval_ms: i32, cb: F) -> Cmd where F: Fn() -> MSG + 'static, MSG: 'static, @@ -97,23 +97,23 @@ impl Window { interval_ms, ) .expect("Unable to start interval"); - Task::sub(rx, closure_cb) + Cmd::sub(rx, closure_cb) } /// scroll the window to the top of the document - pub fn scroll_to_top(msg: MSG) -> Task + pub fn scroll_to_top(msg: MSG) -> Cmd where MSG: 'static, { use std::future::ready; - Task::single(ready({ + Cmd::single(ready({ util::scroll_window_to_top(); msg })) } /// - pub fn on_popstate(mut cb: F) -> Task + pub fn on_popstate(mut cb: F) -> Cmd where F: FnMut(web_sys::PopStateEvent) -> MSG + 'static, MSG: 'static, @@ -132,6 +132,6 @@ impl Window { closure_cb.as_ref().unchecked_ref(), ) .expect("add event callback"); - Task::sub(rx, closure_cb) + Cmd::sub(rx, closure_cb) } } diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index f10e91eb8..37f93a00c 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -51,7 +51,7 @@ pub mod prelude { pub use crate::html::events::*; pub use crate::dom::{Application, SkipDiff, skip_if, events, Program, document, now, window, Window, Dispatch, AnimationFrameHandle, Component, StatefulComponent, Effects, Measurements, MountAction, - MountTarget, Task, TimeoutCallbackHandle, DomAttrValue, + MountTarget, Cmd, TimeoutCallbackHandle, DomAttrValue, stateful_component, }; #[cfg(feature = "custom_element")] diff --git a/examples/fetch-data-component/README.md b/examples/fetch-data-component/README.md index 70a77a50d..97ce1a590 100644 --- a/examples/fetch-data-component/README.md +++ b/examples/fetch-data-component/README.md @@ -2,3 +2,5 @@ This is an example derived from the fetch-data examples, but instead of fetching the data from the Application, we are fetching the data at the Component level. + +TODO: There is something wrong with fetching the data here.. diff --git a/examples/fetch-data-component/src/fetcher.rs b/examples/fetch-data-component/src/fetcher.rs index 1eaca188c..1fad1e8a8 100644 --- a/examples/fetch-data-component/src/fetcher.rs +++ b/examples/fetch-data-component/src/fetcher.rs @@ -48,8 +48,9 @@ impl Fetcher { fn fetch_page(&self) -> Effects { let url = format!("{}?page={}&per_page={}", DATA_URL, self.page, PER_PAGE); + log::info!("url: {}", url); - Effects::with_local_async([async move { + Effects::from(Cmd::single(async move { match Http::fetch_text(&url).await { Ok(v) => match serde_json::from_str(&v) { Ok(data1) => Msg::ReceivedData(data1), @@ -57,7 +58,7 @@ impl Fetcher { }, Err(e) => Msg::RequestError(e), } - }]) + })) } } @@ -81,10 +82,13 @@ impl Component for Fetcher { Msg::PrevPage } /> - {text(format!("Page: {}", self.page))} + {text(format!("Page: {}, total_page: {}", self.page, self.data.total_pages))} = self.data.total_pages} + // disabled={self.page >= self.data.total_pages} value="Next Page >>" + data = self.data.total_pages + data_page = self.page + should_disable = {self.page >= self.data.total_pages} on_click=|_|{ trace!("Button is clicked"); Msg::NextPage @@ -134,6 +138,7 @@ impl Component for Fetcher { self.fetch_page() } Msg::ReceivedData(data1) => { + log::info!("got data: {:#?}", data1); self.data = data1; Effects::none() } diff --git a/examples/fetch-data-component/src/lib.rs b/examples/fetch-data-component/src/lib.rs index 9f8f3a1b7..8c9a3310d 100644 --- a/examples/fetch-data-component/src/lib.rs +++ b/examples/fetch-data-component/src/lib.rs @@ -27,7 +27,7 @@ impl App { impl Application for App { type MSG = Msg; - fn init(&mut self) -> Cmd { + fn init(&mut self) -> Cmd { console_log::init_with_level(log::Level::Trace).unwrap(); Cmd::from(self.fetcher.init().map_msg(Msg::FetcherMsg)) } @@ -41,7 +41,7 @@ impl Application for App { } } - fn update(&mut self, msg: Msg) -> Cmd { + fn update(&mut self, msg: Msg) -> Cmd { match msg { Msg::FetcherMsg(fmsg) => Cmd::from(self.fetcher.update(fmsg).map_msg(Msg::FetcherMsg)), } diff --git a/examples/fetch-data-macro-syntax/Cargo.toml b/examples/fetch-data-macro-syntax/Cargo.toml index c05300a20..b66c2a61f 100644 --- a/examples/fetch-data-macro-syntax/Cargo.toml +++ b/examples/fetch-data-macro-syntax/Cargo.toml @@ -10,12 +10,13 @@ edition = "2021" crate-type = ["cdylib"] [dependencies] -sauron = { path = "../../" } +sauron = { path = "../../", features = ["log-patches"] } console_error_panic_hook = { version = "0.1" } serde = { version = "1.0", features = ["serde_derive"]} serde_json = "1.0" log = "0.4" console_log = {version="0.2", features = ["color"]} wasm-bindgen-futures = "0.4.32" +reqwest = "0.12" diff --git a/examples/fetch-data-macro-syntax/src/lib.rs b/examples/fetch-data-macro-syntax/src/lib.rs index f8e8729df..64b54cab3 100644 --- a/examples/fetch-data-macro-syntax/src/lib.rs +++ b/examples/fetch-data-macro-syntax/src/lib.rs @@ -1,5 +1,4 @@ -#![deny(warnings)] -use sauron::{dom::spawn_local, dom::Http, js_sys::TypeError, jss, *}; +use sauron::{dom::Http, js_sys::TypeError, jss, *}; use serde::Deserialize; #[macro_use] @@ -50,11 +49,12 @@ impl App { } } - fn fetch_page(&self) -> Cmd { + fn fetch_page(&self) -> Cmd { let url = format!("{}?page={}&per_page={}", DATA_URL, self.page, PER_PAGE); - Cmd::new(|mut program| { - spawn_local(async move { + /* + Cmd::single( + async move { let msg = match Http::fetch_text(&url).await { Ok(v) => match serde_json::from_str(&v) { Ok(data1) => Msg::ReceivedData(data1), @@ -62,26 +62,41 @@ impl App { }, Err(e) => Msg::RequestError(e), }; - program.dispatch(msg); - }) - }) + msg + } + ) + */ + Cmd::single( + async move{ + let response = reqwest::Client::new() + .get(url) + .send() + .await.expect("dont error pls"); + + match serde_json::from_str(&response.text().await.unwrap()) { + Ok(data1) => Msg::ReceivedData(data1), + Err(err) => Msg::JsonError(err), + } + } + ) } } impl Application for App { type MSG = Msg; - fn init(&mut self) -> Cmd { + fn init(&mut self) -> Cmd { console_log::init_with_level(log::Level::Trace).unwrap(); self.fetch_page() } fn view(&self) -> Node { + log::info!("disabled: {}", {self.page <= 1}); node! {
{text(format!("Page: {}", self.page))} = self.data.total_pages} + {disabled(self.page >= self.data.total_pages)} value="Next Page >>" on_click=|_|{ trace!("Button is clicked"); @@ -123,7 +138,7 @@ impl Application for App { } } - fn update(&mut self, msg: Msg) -> Cmd { + fn update(&mut self, msg: Msg) -> Cmd { trace!("App is updating from msg: {:?}", msg); match msg { Msg::NextPage => { diff --git a/examples/fetch-data/src/lib.rs b/examples/fetch-data/src/lib.rs index 226dcab66..1bfb39792 100644 --- a/examples/fetch-data/src/lib.rs +++ b/examples/fetch-data/src/lib.rs @@ -4,7 +4,7 @@ use sauron::html::attributes::*; use sauron::html::events::*; use sauron::html::*; use sauron::js_sys::TypeError; -use sauron::{jss, text, wasm_bindgen, Application, Node, Program, Task}; +use sauron::{jss, text, wasm_bindgen, Application, Node, Program, Cmd}; use serde::Deserialize; #[macro_use] @@ -55,9 +55,9 @@ impl App { } } - fn fetch_page(&self) -> Task { + fn fetch_page(&self) -> Cmd { let url = format!("{}?page={}&per_page={}", DATA_URL, self.page, PER_PAGE); - Task::single( + Cmd::single( async move { let msg = match Http::fetch_text(&url).await { Ok(v) => match serde_json::from_str(&v) { @@ -75,7 +75,7 @@ impl App { impl Application for App { type MSG = Msg; - fn init(&mut self) -> Task { + fn init(&mut self) -> Cmd { console_log::init_with_level(log::Level::Trace).unwrap(); self.fetch_page() } @@ -139,7 +139,7 @@ impl Application for App { ) } - fn update(&mut self, msg: Msg) -> Task { + fn update(&mut self, msg: Msg) -> Cmd { trace!("App is updating from msg: {:?}", msg); match msg { Msg::NextPage => { @@ -147,7 +147,7 @@ impl Application for App { self.page += 1; self.fetch_page() } else { - Task::none() + Cmd::none() } } Msg::PrevPage => { @@ -158,12 +158,12 @@ impl Application for App { } Msg::ReceivedData(data1) => { self.data = data1; - Task::none() + Cmd::none() } Msg::JsonError(err) => { trace!("Error fetching users! {:#?}", err); self.error = Some(format!("There was an error fetching the page: {:?}", err)); - Task::none() + Cmd::none() } Msg::RequestError(type_error) => { trace!("Error requesting the page: {:?}", type_error); @@ -171,7 +171,7 @@ impl Application for App { "There was an error fetching the page: {:?}", type_error )); - Task::none() + Cmd::none() } } } diff --git a/examples/interactive-macro-syntax/src/app.rs b/examples/interactive-macro-syntax/src/app.rs index 7548000c4..68c50c65e 100644 --- a/examples/interactive-macro-syntax/src/app.rs +++ b/examples/interactive-macro-syntax/src/app.rs @@ -36,11 +36,11 @@ impl App { impl Application for App { type MSG = Msg; - fn init(&mut self) -> Task { + fn init(&mut self) -> Cmd { Window::every_interval(1_000, || Msg::Clock) } - fn update(&mut self, msg: Msg) -> Task { + fn update(&mut self, msg: Msg) -> Cmd { match msg { Msg::Click => { self.click_count += 1; @@ -66,7 +66,7 @@ impl Application for App { } } } - Task::none() + Cmd::none() } view! { diff --git a/examples/resize/src/lib.rs b/examples/resize/src/lib.rs index 5a493514e..17df254f0 100644 --- a/examples/resize/src/lib.rs +++ b/examples/resize/src/lib.rs @@ -16,8 +16,8 @@ pub struct App { impl Application for App { type MSG = Msg; - fn init(&mut self) -> Task { - Task::batch([ + fn init(&mut self) -> Cmd { + Cmd::batch([ Window::on_resize(|w, h| { log::info!("This will trigger only once.. {w}x{h}"); Msg::WindowResized(w, h) @@ -50,17 +50,17 @@ impl Application for App { ) } - fn update(&mut self, msg: Msg) -> Task { + fn update(&mut self, msg: Msg) -> Cmd { match msg { Msg::WindowResized(w, h) => { log::info!("Setting the App's width: {w} and height: {h}"); self.width = Some(w); self.height = Some(h); - Task::none() + Cmd::none() } Msg::TickTock => { log::info!("tick tock!"); - Task::none() + Cmd::none() } } }