From 906711c8736fa30f0d1af0d4d89f398aa77152c1 Mon Sep 17 00:00:00 2001 From: Brian Carlsen Date: Sun, 15 Dec 2024 12:32:10 -0700 Subject: [PATCH 1/2] Add section on local reactivity. --- src/reactivity/working_with_signals.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/reactivity/working_with_signals.md b/src/reactivity/working_with_signals.md index 762a44d..6f0fd6e 100644 --- a/src/reactivity/working_with_signals.md +++ b/src/reactivity/working_with_signals.md @@ -60,6 +60,17 @@ if names.read().is_empty() { Now our function simply takes `names` by reference to run `is_empty()`, avoiding that clone, and then mutates the `Vec<_>` in place. +## Local Reactivity + +So far we have looked at a CSR-only application. This means our app will run on a single thread. However, if you look at the signature of [`signal`](https://docs.rs/leptos/latest/leptos/reactive/signal/fn.signal.html) it requires our value be `Send + Sync`, which is meant for multi-threaded applications. This requirement exists so [SSR applications](../ssr/README.md) can parallelize their work. If you only plan on having a CSR app, the reactive primatives are paired with local alternatives that alleviate the `Send + Sync` requirement. + +| Standard | Local | +| -------- | ----- | +| [`signal`](https://docs.rs/leptos/latest/leptos/reactive/signal/fn.signal.html) | [`signal_local`](https://docs.rs/leptos/latest/leptos/prelude/fn.signal_local.html) | +| [`RwSignal::new`](https://docs.rs/leptos/latest/leptos/prelude/struct.RwSignal.html#method.new) | [`RwSignal::new_local`](https://docs.rs/leptos/latest/leptos/prelude/struct.RwSignal.html#method.new_local) | +| [`Resource`](https://docs.rs/leptos/latest/leptos/prelude/struct.Resource.html) | [`LocalResource`](https://docs.rs/leptos/latest/leptos/prelude/struct.LocalResource.html) | +| [`Action::new`](https://docs.rs/leptos/latest/leptos/prelude/struct.Action.html#method.new) | [`Action::new_local`](https://docs.rs/leptos/latest/leptos/prelude/struct.Action.html#method.new_local), [`Action::new_unsync`](https://docs.rs/leptos/latest/leptos/prelude/struct.Action.html#method.new_unsync) | + ## Nightly Syntax When using the `nightly` feature and `nightly` syntax, calling a `ReadSignal` as a function is syntax sugar for `.get()`. Calling a `WriteSignal` as a function is syntax sugar for `.set()`. So From 962be5904e93583da1ef6c1661c3ef2b185d02db Mon Sep 17 00:00:00 2001 From: bicarlsen Date: Sun, 15 Dec 2024 20:45:45 +0100 Subject: [PATCH 2/2] Update working_with_signals.md --- src/reactivity/working_with_signals.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reactivity/working_with_signals.md b/src/reactivity/working_with_signals.md index b478ec2..2e1585e 100644 --- a/src/reactivity/working_with_signals.md +++ b/src/reactivity/working_with_signals.md @@ -62,7 +62,7 @@ Now our function simply takes `names` by reference to run `is_empty()`, avoiding ## Local Reactivity -So far we have looked at a CSR-only application. This means our app will run on a single thread. However, if you look at the signature of [`signal`](https://docs.rs/leptos/latest/leptos/reactive/signal/fn.signal.html) it requires our value be `Send + Sync`, which is meant for multi-threaded applications. This requirement exists so [SSR applications](../ssr/README.md) can parallelize their work. If you only plan on having a CSR app, the reactive primatives are paired with local alternatives that alleviate the `Send + Sync` requirement. +So far we have looked at a CSR-only application. This means our app will run on a single thread. However, if you look at the signature of [`signal`](https://docs.rs/leptos/latest/leptos/reactive/signal/fn.signal.html) it requires our value be `Send + Sync`, which is meant for multi-threaded applications. This requirement exists so [SSR applications](../ssr/README.md) can parallelize their work. If you have a CSR-only app, so don't need multi-threading, the reactive primatives are paired with local alternatives that alleviate the `Send + Sync` requirement. | Standard | Local | | -------- | ----- |