Skip to content

Commit 06a7b0d

Browse files
doc: add explanation to the effect example
1 parent 68291a7 commit 06a7b0d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/signal-polyfill/readme.md

+6
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ Depending on how the effect is implemented, the above code could result in an in
4242

4343
### Creating a simple effect
4444

45+
* You can use `Signal.subtle.Watch(callback)` combined with `Signal.Computed(callback)` to create a simple _effect_ implementation.
46+
* The `Signal.subtle.Watch` `callback` is invoked synchronously when a watched signal becomes dirty.
47+
* To batch effect updates, library authors are expected to implement their own schedulers.
48+
* Use `Signal.subtle.Watch#getPending()` to retrieve an array of dirty signals.
49+
* Calling `Signal.subtle.Watch#watch()` with no arguments will re-watch the list of tracked signals again.
50+
4551
```js
4652
import { Signal } from "signal-polyfill";
4753

0 commit comments

Comments
 (0)