Skip to content

Commit 1f39299

Browse files
committed
Fix doctest in create_slice and edit doc comment slightly
1 parent 2be4610 commit 1f39299

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

leptos_reactive/src/slice.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
use crate::{create_memo, IntoSignalSetter, RwSignal, Scope, Signal, SignalSetter};
22

3-
/// derives a reactive slice from an [RwSignal](crate::RwSignal)
3+
/// Derives a reactive slice of an [RwSignal](crate::RwSignal).
44
///
5-
/// Slices have the same guarantees as [Memos](crate::Memo),
5+
/// Slices have the same guarantees as [Memos](crate::Memo):
66
/// they only emit their value when it has actually been changed.
77
///
8-
/// slices need a getter and a setter, and you must make sure that
8+
/// Slices need a getter and a setter, and you must make sure that
99
/// the setter and getter only touch their respective field and nothing else.
1010
/// They optimally should not have any side effects.
1111
///
12-
/// you can use slices whenever you want to react to only parts
13-
/// of a bigger signal, the prime example would be state management
14-
/// where you want all state variables grouped up but also need
12+
/// You can use slices whenever you want to react to only parts
13+
/// of a bigger signal. The prime example would be state management,
14+
/// where you want all state variables grouped together, but also need
1515
/// fine-grained signals for each or some of these variables.
1616
/// In the example below, setting an auth token will only trigger
1717
/// the token signal, but none of the other derived signals.
18-
///
1918
/// ```
2019
/// # use leptos_reactive::*;
2120
/// # let (cx, disposer) = raw_scope_and_disposer(create_runtime());
@@ -49,13 +48,14 @@ use crate::{create_memo, IntoSignalSetter, RwSignal, Scope, Signal, SignalSetter
4948
/// );
5049
/// let count_token_updates = create_rw_signal(cx, 0);
5150
/// count_token_updates.with(|counter| assert_eq!(counter, &0));
52-
/// create_effect(cx, move |_| {
53-
/// token.with(|_| {});
51+
/// create_isomorphic_effect(cx, move |_| {
52+
/// _ = token.with(|_| {});
5453
/// count_token_updates.update(|counter| *counter += 1)
5554
/// });
5655
/// count_token_updates.with(|counter| assert_eq!(counter, &1));
5756
/// set_token.set("this is not a token!".into());
5857
/// // token was updated with the new token
58+
/// token.with(|token| assert_eq!(token, "this is not a token!"));
5959
/// count_token_updates.with(|counter| assert_eq!(counter, &2));
6060
/// set_dark_mode.set(true);
6161
/// // since token didn't change, there was also no update emitted

0 commit comments

Comments
 (0)