Skip to content

Commit

Permalink
doc: add explanation to the effect example
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Mar 27, 2024
1 parent 68291a7 commit 06a7b0d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/signal-polyfill/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ Depending on how the effect is implemented, the above code could result in an in

### Creating a simple effect

* You can use `Signal.subtle.Watch(callback)` combined with `Signal.Computed(callback)` to create a simple _effect_ implementation.
* The `Signal.subtle.Watch` `callback` is invoked synchronously when a watched signal becomes dirty.
* To batch effect updates, library authors are expected to implement their own schedulers.
* Use `Signal.subtle.Watch#getPending()` to retrieve an array of dirty signals.
* Calling `Signal.subtle.Watch#watch()` with no arguments will re-watch the list of tracked signals again.

```js
import { Signal } from "signal-polyfill";

Expand Down

0 comments on commit 06a7b0d

Please sign in to comment.