Skip to content

Commit

Permalink
fix: Applications to use Task
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanceras committed Apr 1, 2024
1 parent 2b66ce9 commit f2a8d7b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
10 changes: 10 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,16 @@
- [ ] enum Task{Cmd,Sub} into one unified type.
- Sauron just consilidate them into one enum struct for simplicity
- [ ] Remove `Modifier` and `measurements`
- [ ] Have a measurement in the Application trait
- [ ] Remove StatefulComponent as it is now the same as Application and serve the same purpose
- add methods for Application:
- attribute_changed
- remove_attribute
- append_child
- remove_child
- connected_callback
- disconnected_callback
- adopted_callback

## Features
- [X] Storage service (May not be needed since the user can directly use web-sys)
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/dom/program/app_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ where

#[cfg(feature = "with-measure")]
pub fn measurements(&self, measurements: Measurements) -> Dispatch<APP> {
self.app.borrow().measurements(measurements).no_render()
Dispatch::from(self.app.borrow().measurements(measurements).no_render())
}

pub fn push_msgs(&mut self, msgs: impl IntoIterator<Item = APP::MSG>) {
Expand Down
7 changes: 4 additions & 3 deletions examples/counter/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use sauron::{
html::text, html::units::px, jss, node, wasm_bindgen, Application, Dispatch, Node, Program,
html::text, html::units::px, jss, node, wasm_bindgen, Application, Node, Program,
Task,
};

enum Msg {
Expand Down Expand Up @@ -41,13 +42,13 @@ impl Application for App {
}
}

fn update(&mut self, msg: Msg) -> Dispatch<Self> {
fn update(&mut self, msg: Msg) -> Task<Msg> {
match msg {
Msg::Increment => self.count += 1,
Msg::Decrement => self.count -= 1,
Msg::Reset => self.count = 0,
}
Dispatch::none()
Task::none()
}

fn stylesheet() -> Vec<String> {
Expand Down
4 changes: 2 additions & 2 deletions examples/js-performance-benchmark-sauron/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ enum Msg {
impl Application for App {
type MSG = Msg;

fn update(&mut self, msg: Msg) -> Cmd<Self> {
fn update(&mut self, msg: Msg) -> Task<Msg> {
match msg {
Msg::Run(amount) => {
let rng = &mut self.rng;
Expand Down Expand Up @@ -171,7 +171,7 @@ impl Application for App {
}
}
}
Cmd::none()
Task::none()
}

view! {
Expand Down

0 comments on commit f2a8d7b

Please sign in to comment.