Skip to content

Commit

Permalink
refactor: Only explicitly document @preact/signals usage (#1135)
Browse files Browse the repository at this point in the history
  • Loading branch information
rschristian committed May 27, 2024
1 parent de4f589 commit f9765ae
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions content/en/guide/v10/signals.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ Signals are effective in applications of any size, with ergonomics that speed up

---

**Important**

This guide will go over using Signals in Preact, and while this is largely applicable to both the Core and React libraries, there will be some usage differences. The best references for their usage is in their respective docs: [`@preact/signals-core`](https://github.com/preactjs/signals), [`@preact/signals-react`](https://github.com/preactjs/signals/tree/main/packages/react)

---

<div><toc></toc></div>

---
Expand Down Expand Up @@ -341,7 +347,7 @@ This poses a question: how can we subscribe to signals outside of the component
To run arbitrary code in response to signal changes, we can use [`effect(fn)`](#effectfn). Similar to computed signals, effects track which signals are accessed and re-run their callback when those signals change. Unlike computed signals, [`effect()`](#effectfn) does not return a signal - it's the end of a sequence of changes.

```js
import { signal, computed, effect } from "@preact/signals-core";
import { signal, computed, effect } from "@preact/signals";

const name = signal("Jane");
const surname = signal("Doe");
Expand Down Expand Up @@ -369,7 +375,7 @@ effect(() => {
You can destroy an effect and unsubscribe from all signals it accessed by calling the returned function.

```js
import { signal, effect } from "@preact/signals-core";
import { signal, effect } from "@preact/signals";

const name = signal("Jane");
const surname = signal("Doe");
Expand Down Expand Up @@ -441,7 +447,7 @@ Accessing a signal that has been modified within a batch will reflect its update

```js
// --repl
import { signal, computed, effect, batch } from "@preact/signals-core";
import { signal, computed, effect, batch } from "@preact/signals";

const count = signal(0);
const double = computed(() => count.value * 2);
Expand Down

0 comments on commit f9765ae

Please sign in to comment.