From 001930b14f5dbbc57c7d3691f5efc46dbd22b5c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Blanchard?= <1567759+francois-blanchard@users.noreply.github.com> Date: Sun, 4 Feb 2024 01:10:42 +0100 Subject: [PATCH] docs: :memo: use `nightly` Rust shorthand in the basics (#51) --- src/view/01_basic_component.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/view/01_basic_component.md b/src/view/01_basic_component.md index 1f0c39a..0d917b0 100644 --- a/src/view/01_basic_component.md +++ b/src/view/01_basic_component.md @@ -28,11 +28,13 @@ fn App() -> impl IntoView { view! { } } @@ -88,14 +90,13 @@ view! { } ``` @@ -105,7 +106,7 @@ This should mostly be easy to understand: it looks like HTML, with a special a Rust string, and then... ```rust -{move || count.get()} +{move || count()} ``` whatever that is. @@ -115,7 +116,7 @@ than they’ve ever used in their lives. And fair enough. Basically, passing a f into the view tells the framework: “Hey, this is something that might change.” When we click the button and call `set_count`, the `count` signal is updated. This -`move || count.get()` closure, whose value depends on the value of `count`, reruns, +`move || count()` closure, whose value depends on the value of `count`, reruns, and the framework makes a targeted update to that one specific text node, touching nothing else in your application. This is what allows for extremely efficient updates to the DOM. @@ -129,7 +130,7 @@ As a result, you can write a simpler view: view! { } @@ -199,7 +200,7 @@ fn App() -> impl IntoView { // you can insert Rust expressions as values in the DOM // by wrapping them in curly braces // if you pass in a function, it will reactively update - {move || count.get()} + {move || count()}

"Reactive shorthand: "