From f5b97276345d2b1c6d1383c8a7926a2ca2e03ae1 Mon Sep 17 00:00:00 2001 From: TatriX Date: Wed, 11 Dec 2019 12:20:25 +0100 Subject: [PATCH 1/9] Update structure.md --- crate/guides/structure.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crate/guides/structure.md b/crate/guides/structure.md index 965365c..5da2cc2 100644 --- a/crate/guides/structure.md +++ b/crate/guides/structure.md @@ -25,7 +25,7 @@ impl Default for Model { ``` In this example, we initialize using Rust’s `Default` trait, in order to keep the initialization code by the - model struct. When we call `Model.default()`, it initializes with these values. We could + model struct. When we call `Model::default()`, it initializes with these values. We could also initialize it using a constructor method, or a struct literal. Note the use of `into()` on our `&str` literal, to convert it into an owned `String`. From 9142c7c51e80f1a7cabe67bb2d0d05ff46ac1fc7 Mon Sep 17 00:00:00 2001 From: TatriX Date: Wed, 11 Dec 2019 12:24:43 +0100 Subject: [PATCH 2/9] Update about.md --- crate/guides/about.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crate/guides/about.md b/crate/guides/about.md index b5a3749..493d21c 100644 --- a/crate/guides/about.md +++ b/crate/guides/about.md @@ -32,7 +32,7 @@ are worth it. ## Where to start if you're familiar with existing frontend frameworks -Check out the (Code comparison)[https://seed-rs.org/guide/code-comarison]) section of this guide. Additionally, +Check out the [Code comparison](https://seed-rs.org/guide/code-comarison) section of this guide. Additionally, the [todomvc example](https://github.com/seed-rs/seed/tree/master/examples/todomvc) is an implementation of the [TodoMVC project](https://todomvc.com/), which has example code in other frameworks that produce identitcal apps. Compare the example in this From 46a6f0d8490c7892bc7f2933e827982c03b29951 Mon Sep 17 00:00:00 2001 From: TatriX Date: Wed, 11 Dec 2019 12:33:29 +0100 Subject: [PATCH 3/9] Update structure.md Text says that `update` function returns `Update` struct. But in the code example it actually doesn't. I'm not yet sure how to fix it. --- crate/guides/structure.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crate/guides/structure.md b/crate/guides/structure.md index 5da2cc2..b1c6f94 100644 --- a/crate/guides/structure.md +++ b/crate/guides/structure.md @@ -68,13 +68,13 @@ enum Msg { ``` The update [function]( https://doc.rust-lang.org/book/ch03-03-how-functions-work.html) -you pass to `App::builder(` describes how the state should change, upon -receiving each type of message. It's the only place where the model is changed. It accepts a message, -and model as parameters, and returns an `Update` struct. `Update` contains `ShouldRender` and `Effect` +you pass to `App::builder()` describes how the state should change, upon +receiving each type of message. It's the only place where the model is changed. It accepts a message +and a model as parameters, and returns an `Update` struct. `Update` contains `ShouldRender` and `Effect` enums. `ShouldRender` and its variants are imported in the prelude, and has variants of -`Render` and `Skip`. Render triggers a rendering update, and will be used in -most cases. `Skip` updates the model without triggering a render, and is useful in animations. +`Render` and `Skip`. Render triggers a rendering update and will be used in +most cases. `Skip` updates the model without triggering a render and is useful in animations. `Effect` isn't exposed in the API: it's used internally to handle async events like fetch requests. See the `Http requests` section for more info. From 925353245a02179106b02b3bcb2add55a2a34011 Mon Sep 17 00:00:00 2001 From: TatriX Date: Wed, 11 Dec 2019 12:46:11 +0100 Subject: [PATCH 4/9] Update structure.md --- crate/guides/structure.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crate/guides/structure.md b/crate/guides/structure.md index b1c6f94..7d40f2a 100644 --- a/crate/guides/structure.md +++ b/crate/guides/structure.md @@ -117,6 +117,8 @@ fn update(msg: Msg, model: &mut Model, _orders: &mut impl Orders) { } ``` +[TODO]: # (This section below is unclear, please improve me) + The third parameter of the update function is an [Orders](https://docs.rs/seed/0.3.4/seed/prelude/struct.Orders.html) struct, imported in the prelude. From 4cd801fc6d8ebbea4e802eb42e488cf653af6c7b Mon Sep 17 00:00:00 2001 From: TatriX Date: Wed, 11 Dec 2019 12:57:26 +0100 Subject: [PATCH 5/9] Update view.md --- crate/guides/view.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/crate/guides/view.md b/crate/guides/view.md index 7002a2f..f7a3cb1 100644 --- a/crate/guides/view.md +++ b/crate/guides/view.md @@ -1,23 +1,21 @@ # View - Visual layout (ie HTML/DOM elements) is described declaratively in Rust, and uses -[macros]( https://doc.rust-lang.org/book/appendix-04-macros.html) to simplify syntax. Each element + Visual layout (ie HTML/DOM elements) is described declaratively with [macros]( https://doc.rust-lang.org/book/appendix-04-macros.html) to simplify syntax. Each element is represented by a macro, eg `div![]`. These act as functions that accept an arbitrary -number of parameters, in any order: They handle the parameters based exclusively on type. +number of parameters in any order. They handle parameters based exclusively on type. -The view's defined by a function that's passed to -[App::builder](https://docs.rs/seed/0.4.2/seed/struct.App.html#method.build). This takes a `&Model` -as its parameter, and outputs something that implements the ` View` trait, which is imported in the prelude. +The view is defined by a function passed to +[App::build()](https://docs.rs/seed/0.4.2/seed/struct.App.html#method.build). It takes a `&Model` +as a parameter and outputs something that implements the ` View` trait, which is imported in the prelude. Usually, this is a `Node`, or `Vec`, representing all nodes that will be inserted as children -on the top-level one. (The top-level `Node` is in the html file, and specified with -[App::builder.mount()](https://docs.rs/seed/0.4.2/seed/struct.AppBuilder.html#method.mount), -or as a default, the element with id `app`). +on the top-level one. The top-level `Node` exists in the DOM as specified by +[AppBuilder::mount()](https://docs.rs/seed/0.4.2/seed/struct.AppBuilder.html#method.mount) and defaults to an element with id `app`. It may composed into sub-functions, which can be thought of like components in other frameworks. Examples: ```rust fn view(model: &Model) -> Node { - h1![ "Let there be light" ], + h1![ "Let there be light" ] } ``` @@ -25,13 +23,15 @@ fn view(model: &Model) -> Node { fn view(model: &Model) -> Vec> { vec![ h1![ "Let there be light" ], - h2![ "Let it be both a particle and a wave" ] + h2![ "Let it be both a particle and a wave" ], ] } ````` In either of those examples, you could use the signature: `fn view(model: &Model) -> impl View` instead. This allows you to change between them without changing the function signature. +[TODO]: # (Explain what `Msg` type parameter means and how it's connected to `update` function) + ## The Node Enum The Virtual DOM is represnted by nested [Nodes](https://docs.rs/seed/0.1.6/seed/dom_types/enum.Node.html). `Node` has 3 variants: From 37512a766d01301c7f3528bcadfca42ca7ebd0d6 Mon Sep 17 00:00:00 2001 From: TatriX Date: Wed, 11 Dec 2019 15:51:42 +0100 Subject: [PATCH 6/9] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7cf5fd5..a2537a5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,6 @@ name: Main -on: [push] +on: [push, pull_request] env: RUST_BACKTRACE: 1 From 3e8c270744464589cce56feaaa9a7e97474106ba Mon Sep 17 00:00:00 2001 From: TatriX Date: Thu, 12 Dec 2019 10:56:36 +0100 Subject: [PATCH 7/9] Update view.md --- crate/guides/view.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crate/guides/view.md b/crate/guides/view.md index f7a3cb1..d198783 100644 --- a/crate/guides/view.md +++ b/crate/guides/view.md @@ -433,6 +433,6 @@ branches must return an `Node` (Or `Vec` of `Node`s) to satisfy Rust's type syst rendered, and its `empty![]` macro alias, which is more concise and consistent: ```rust div![ - if model.count >= 10 { h2![ style!{St::Padding => 50}, "Nice!" ] } else { empty![]) } + if model.count >= 10 { h2![ style!{St::Padding => 50}, "Nice!" ] } else { empty![] } ] ``` From 50b3df0a5c475fdb544e320479ab7ca7da183c36 Mon Sep 17 00:00:00 2001 From: TatriX Date: Thu, 12 Dec 2019 17:49:11 +0100 Subject: [PATCH 8/9] Update events.md --- crate/guides/events.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crate/guides/events.md b/crate/guides/events.md index 2d3cb34..5e7cf15 100644 --- a/crate/guides/events.md +++ b/crate/guides/events.md @@ -70,7 +70,7 @@ keyboard_ev("input", Msg::PutTheHammerDown) Note that in the examples for input_ev and keyboard_ev, the syntax is simplified since we're only passing the field text, and keyboard event respectively to the Msg. The input_ev -example is Rust shorthand for ```input_ev("input, |text| Msg::NewWords(text)```. If you were +example is Rust shorthand for ```input_ev("input", |text| Msg::NewWords(text))```. If you were to pass something other than, or more than just the input text (Or KeyboardEvent for keyboard_ev, or Event for raw_ev described below), you can't use this shorthand, and would have to do something like this intead, From 8fc4dea90a9d799ca8156a5e1283278355452dd4 Mon Sep 17 00:00:00 2001 From: TatriX Date: Thu, 12 Dec 2019 17:53:20 +0100 Subject: [PATCH 9/9] Update events.md --- crate/guides/events.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crate/guides/events.md b/crate/guides/events.md index 5e7cf15..d2b57fc 100644 --- a/crate/guides/events.md +++ b/crate/guides/events.md @@ -177,7 +177,7 @@ where it handles text input triggered by a key press, and uses prevent_default() ## Window events We handle events triggered by the overall window specially, since it doesn't fit directly into our virtual DOM. We pass to `App::builder::window_events()` a function that accepts a - ref to `Model`, and returns a `Vec`. We use it to control + ref to `Model`, and returns a `Vec`. We use it to control which listeners are attached to the window based on the model. Excerpt from the [window_events](https://github.com/seed-rs/seed/blob/master/examples/window_events/src/lib.rs) example: