@@ -26,38 +26,37 @@ x: f64,
2626``` rust
2727use whack :: {components :: * , ds};
2828
29- ds :: comp! {
30- pub fn Component1 (
31- /// To which fixture to bind the contained `Label`.
32- #[fixture_opt ]
33- bind : UiComponent ,
34- ) {
35- let x = ds :: use_state :: <f64 >(|| 0.0 );
36- let button = ds :: use_fixture <Option <UiComponent >>(|| None );
37-
38- // Effect
39- ds :: use_effect! ({
40- (* button ). unwrap (). focus ();
41- });
42-
43- ds :: xn! {
44- <w : VGroup s : color = " orange" >
45- // Style sheet scoped to that VGroup tag.
46- <w : Style >
47- r ### "
48- :host {
49- background: red;
50- }
51- " ###
52- </ w : Style >
53- <w : Label bind = {bind }>" counter: {x.get()}" </ w : Label >
54- <w : Button
55- bind = {button }
56- click &= {x . set (x . get () + 1 );}>
57- " increase x"
58- </ w : Button >
59- </ w : VGroup >
60- }
29+ #[ds:: comp]
30+ pub fn Component1 (
31+ /// To which fixture to bind the contained `Label`.
32+ #[fixture_opt ]
33+ bind : UiComponent ,
34+ ) {
35+ let x = ds :: use_state :: <f64 >(|| 0.0 );
36+ let button = ds :: use_fixture <Option <UiComponent >>(|| None );
37+
38+ // Effect
39+ ds :: use_effect! ({
40+ (* button ). unwrap (). focus ();
41+ });
42+
43+ ds :: xn! {
44+ <w : VGroup s : color = " orange" >
45+ // Style sheet scoped to that VGroup tag.
46+ <w : Style >
47+ r ### "
48+ :host {
49+ background: red;
50+ }
51+ " ###
52+ </ w : Style >
53+ <w : Label bind = {bind }>" counter: {x.get()}" </ w : Label >
54+ <w : Button
55+ bind = {button }
56+ click &= {x . set (x . get () + 1 );}>
57+ " increase x"
58+ </ w : Button >
59+ </ w : VGroup >
6160 }
6261}
6362```
@@ -151,7 +150,7 @@ bind={|val| {
151150
152151## Fields
153152
154- Component fields are the parameters it receives in the ` whack::ds::comp! ` macro.
153+ Component fields are the parameters it receives in the ` whack::ds::comp ` attribute macro.
155154
156155### String
157156
@@ -185,8 +184,8 @@ pub fn set_x<S: AsRef<str>>(&self, s: impl Into<Option<S>>) {
185184### Function
186185
187186``` rust
188- x : Fn (... ),
189- x : Fn (... ) -> T ,
187+ x : impl Fn (... ),
188+ x : impl Fn (... ) -> T ,
190189```
191190
192191yields a ` Rc<dyn Fn(...) + 'static> ` field.
@@ -196,8 +195,8 @@ During memoization, equality always returns `true` to avoid re-rendering the com
196195### Function (optional)
197196
198197``` rust
199- x : Option <Fn (... )>,
200- x : Option <Fn (... ) -> T >,
198+ x : Option <impl Fn (... )>,
199+ x : Option <impl Fn (... ) -> T >,
201200```
202201
203202yields an ` Option<Rc<dyn Fn(...) + 'static>> ` field.
0 commit comments