mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 14:54:16 +00:00
docs: correct docs for create_memo
to reflect laziness (#1388)
This commit is contained in:
parent
9e7c31d1e4
commit
8f45daeca8
1 changed files with 7 additions and 7 deletions
|
@ -57,15 +57,15 @@ use std::{any::Any, cell::RefCell, fmt, marker::PhantomData, rc::Rc};
|
|||
/// });
|
||||
///
|
||||
/// // instead, we create a memo
|
||||
/// // 🆗 run #1: the calculation runs once immediately
|
||||
/// // ✅ creation: the computation does not run on creation, because memos are lazy
|
||||
/// let memoized = create_memo(cx, move |_| really_expensive_computation(value.get()));
|
||||
/// create_effect(cx, move |_| {
|
||||
/// // 🆗 reads the current value of the memo
|
||||
/// // 🆗 run #1: reading the memo for the first time causes the computation to run for the first time
|
||||
/// // can be `memoized()` on nightly
|
||||
/// log::debug!("memoized = {}", memoized.get());
|
||||
/// });
|
||||
/// create_effect(cx, move |_| {
|
||||
/// // ✅ reads the current value **without re-running the calculation**
|
||||
/// // ✅ reads the current value again **without re-running the calculation**
|
||||
/// let value = memoized.get();
|
||||
/// // do something else...
|
||||
/// });
|
||||
|
@ -149,15 +149,15 @@ where
|
|||
/// });
|
||||
///
|
||||
/// // instead, we create a memo
|
||||
/// // 🆗 run #1: the calculation runs once immediately
|
||||
// // ✅ creation: the computation does not run on creation, because memos are lazy
|
||||
/// let memoized = create_memo(cx, move |_| really_expensive_computation(value.get()));
|
||||
/// create_effect(cx, move |_| {
|
||||
/// // 🆗 reads the current value of the memo
|
||||
/// // 🆗 run #1: reading the memo for the first time causes the computation to run for the first time
|
||||
/// // can be `memoized()` on nightly
|
||||
/// log::debug!("memoized = {}", memoized.get());
|
||||
/// });
|
||||
/// create_effect(cx, move |_| {
|
||||
/// // ✅ reads the current value **without re-running the calculation**
|
||||
/// // can be `memoized()` on nightly
|
||||
/// // ✅ reads the current value again **without re-running the calculation**
|
||||
/// let value = memoized.get();
|
||||
/// // do something else...
|
||||
/// });
|
||||
|
|
Loading…
Reference in a new issue