@@ -76,13 +76,14 @@ crate-type = ["cdylib"]
7676
7777[dependencies ]
7878seed = " ^0.2.4"
79- wasm-bindgen = " ^0.2.33 "
79+ wasm-bindgen = " ^0.2.38 "
8080web-sys = " ^0.3.6"
8181```
8282
8383## A short example
8484Here's an example demonstrating structure and syntax; it can be found in working form
85- under ` examples/counter ` . Descriptions of its parts are in the
85+ in the [ counter example] ( https://github.com/David-OConnor/seed/tree/master/examples/counter )
86+ Descriptions of its parts are in the
8687Guide section below. Its structure follows [ The Elm Architecture] ( https://guide.elm-lang.org/architecture/ ) .
8788
8889* lib.rs* :
@@ -119,13 +120,14 @@ enum Msg {
119120 ChangeWWC (String ),
120121}
121122
122- /// The sole source of updating the model; returns a fresh one.
123- fn update (msg : Msg , model : Model ) -> Update <Msg , Model > {
123+ /// The sole source of updating the model
124+ fn update (msg : Msg , model : & mut Model ) -> Update <Msg > {
124125 match msg {
125- Msg :: Increment => Render ( Model { count : model . count + 1 , .. model }) ,
126- Msg :: Decrement => Render ( Model { count : model . count - 1 , .. model }) ,
127- Msg :: ChangeWWC (what_we_count ) => Render ( Model { what_we_count , .. model })
126+ Msg :: Increment => model . count += 1 ,
127+ Msg :: Decrement => model . count -= 1 ,
128+ Msg :: ChangeWWC (what_we_count ) => model . what_we_count = what_we_count ,
128129 }
130+ Render . into ()
129131}
130132
131133
@@ -143,7 +145,7 @@ fn success_level(clicks: i32) -> El<Msg> {
143145}
144146
145147/// The top-level component we pass to the virtual dom.
146- fn view (state : seed :: App < Msg , Model >, model : & Model ) -> El <Msg > {
148+ fn view (model : & Model ) -> El <Msg > {
147149 let plural = if model . count == 1 {"" } else {" s" };
148150
149151 // Attrs, Style, Events, and children may be defined separately.
@@ -220,7 +222,7 @@ navigate to that folder in a terminal,
220222run the build script for your system (` build.sh ` or ` build.ps1 ` ), then start a dev server
221223 as described above. Note that if you copy an example to a separate folder, you'll need
222224to edit its ` Cargo.toml ` to point to the package on [ crates.io] ( https://crates.io ) instead of locally: Ie replace
223- ` seed = { path = "../../" ` with ` seed = "^0.2.4 " ` , and in the build script, remove the leading ` ../../ ` on the second
225+ ` seed = { path = "../../" ` with ` seed = "^0.3.0 " ` , and in the build script, remove the leading ` ../../ ` on the second
224226line.
225227
226228
0 commit comments