Skip to content

Commit

Permalink
v0.3.4 release
Browse files Browse the repository at this point in the history
  • Loading branch information
David-OConnor committed May 17, 2019
1 parent 25b2040 commit 5a8850c
Show file tree
Hide file tree
Showing 25 changed files with 1,227 additions and 245 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Changelog

## v0.3.4
- The `update` fn now returns `impl vdom::Updater`, allowing more concise syntax. Non-breaking.
- The `update` fn now accepts a (new) `Orders` struct, and returns nothing. Renders occur implicitly,
with the option to skip rendering, update with an additional message, or perform an asynchronous
action. (Breaking)
- `.mount()` now accepts elements. Deprecated `.mount_el()`
- The `log` function and macro now support items which implement `Debug`
- Removed deprecated `routing::push_path` function (breaking)
Expand Down
68 changes: 0 additions & 68 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ members = [
"examples/orders",
# "examples/server_integration", # has own workspace
"examples/server_interaction",
"examples/server_interaction_detailed",
# "examples/server_interaction_detailed", # has own workspace
"examples/todomvc",
"examples/update_from_js",
"examples/websocket",
Expand All @@ -92,4 +92,5 @@ members = [
exclude = [
# it has own workspace
"examples/server_integration",
"examples/server_interaction_detailed",
]
18 changes: 8 additions & 10 deletions examples/orders/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#[macro_use]
extern crate seed;

use seed::prelude::*;
use futures::prelude::*;
use gloo_timers::future::TimeoutFuture;
use seed::prelude::*;

// Model

Expand Down Expand Up @@ -34,34 +34,33 @@ fn update(msg: Msg, model: &mut Model, orders: &mut Orders<Msg>) {
.send_msg(Msg::WriteHello)
.send_msg(Msg::WriteName("World".into()))
.perform_cmd(write_exclamation_marks_after_delay())
.perform_cmd(write_emoticon_after_delay(":)".into()));
.perform_cmd(write_emoticon_after_delay("🙂".into()));
}
Msg::WriteHello => model.title.push_str("Hello "),
Msg::WriteName(name) => model.title.push_str(&name),
Msg::WriteExclamationMarks => model.title.push_str("!!! "),
Msg::WriteEmoticon(emoticon) => model.title.push_str(&emoticon),
Msg::TimeoutError => {
log!("Timeout failed!");
error!("Timeout failed!");
orders.skip();
}
}
}

fn write_exclamation_marks_after_delay() -> impl Future<Item=Msg, Error=Msg> {
fn write_exclamation_marks_after_delay() -> impl Future<Item = Msg, Error = Msg> {
TimeoutFuture::new(1_000)
.map(|_| Msg::WriteExclamationMarks)
.map_err(|_| Msg::TimeoutError)
}

fn write_emoticon_after_delay(emoticon: String) -> impl Future<Item=Msg, Error=Msg> {
fn write_emoticon_after_delay(emoticon: String) -> impl Future<Item = Msg, Error = Msg> {
TimeoutFuture::new(2_000)
.map(|_| Msg::WriteEmoticon(emoticon))
.map_err(|_| Msg::TimeoutError)
}

// View


fn view(model: &Model) -> impl ElContainer<Msg> {
div![
style![
Expand All @@ -73,9 +72,7 @@ fn view(model: &Model) -> impl ElContainer<Msg> {
"height" => "50vmin";
],
if model.greet_clicked {
h1![
model.title
]
h1![model.title]
} else {
div![
style![
Expand All @@ -85,7 +82,8 @@ fn view(model: &Model) -> impl ElContainer<Msg> {
"cursor" => "pointer";
"box-shadow" => "0 0.5vmin 0.5vmin green";
],
simple_ev(Ev::Click, Msg::Greet), "Greet!"
simple_ev(Ev::Click, Msg::Greet),
"Greet!"
]
}
]
Expand Down
16 changes: 5 additions & 11 deletions examples/server_interaction/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ impl Default for Model {
}
}


#[derive(Clone)]
enum Msg {
Replace(Branch),
Expand All @@ -101,30 +100,25 @@ fn update(msg: Msg, model: &mut Model, orders: &mut Orders<Msg>) {
Msg::Replace(data) => model.data = data,

Msg::GetData => {
orders
.skip()
.perform_cmd(get_data());
},
orders.skip().perform_cmd(get_data());
}

Msg::Send => {
orders
.skip()
.perform_cmd(send());
},
orders.skip().perform_cmd(send());
}

Msg::OnServerResponse(result) => {
log!(format!("Response: {:?}", result));
orders.skip();
}

Msg::OnFetchErr(err) => {
log!(format!("Fetch error: {:?}", err));
error!(format!("Fetch error: {:?}", err));
orders.skip();
}
}
}


fn view(model: &Model) -> Vec<El<Msg>> {
vec![
div![format!(
Expand Down
6 changes: 0 additions & 6 deletions examples/server_interaction_detailed/.gitignore

This file was deleted.

Loading

0 comments on commit 5a8850c

Please # to comment.