mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 14:54:16 +00:00
Fixing ch04 reactivity example (incomplete)
This commit is contained in:
parent
05f635f4ac
commit
876aa0f0f4
1 changed files with 3 additions and 8 deletions
|
@ -2,19 +2,14 @@ use leptos::*;
|
|||
|
||||
fn main() {
|
||||
run_scope(|cx| {
|
||||
let (count, set_count) = create_signal(cx, 0);
|
||||
let (count, set_count) = create_signal(cx, 1);
|
||||
let double_count = move || count() * 2;
|
||||
let fibonacci = create_memo(cx, |prev| {
|
||||
let prev = prev.unwrap_or(1);
|
||||
prev * count()
|
||||
});
|
||||
|
||||
create_effect(cx, |_| {
|
||||
create_effect(cx, move |_| {
|
||||
println!(
|
||||
"count =\t\t{}\ndouble_count = \t{}\nfibonacci = \t\t{}",
|
||||
"count =\t\t{}\ndouble_count = \t{}",
|
||||
count(),
|
||||
double_count(),
|
||||
fibonacci()
|
||||
);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue