Fixing ch04 reactivity example (incomplete)

This commit is contained in:
Greg Johnston 2022-11-13 09:25:22 -05:00
parent 05f635f4ac
commit 876aa0f0f4
1 changed files with 3 additions and 8 deletions

View File

@ -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()
);
});