Skip to content

decouple watch from reactive updates #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion rfcs/0005-standard-signals.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Conceptually, we want to run the reactive update lifecycle in an effect so that
We can do this with an override of `performUpdate()` that wraps ReactiveElement's implementation in a watched computed signal:

```ts
abstract class SignalWatcher extends Base {
class SignalWatcher extends Base {
// Watcher.watch() doesn't dedupe :(
private __watching = false;
private __watcher = new Signal.subtle.Watcher(() => {
Expand Down Expand Up @@ -101,6 +101,10 @@ abstract class SignalWatcher extends Base {
}
```

### effect(callback, options)

An `effect` re-runs the provided callback any time signals accessed inside the callback are set. Effects run a microtask after any signals change. `effect` returns a dispose funcction which can be called to stop the effect from running. By providing `options`, an effect can be associated with an `element` and coordinated with its update cycle.

### watch() directive

The `watch()` async directive accepts a signal and renders its value _asynchronously_ to the containing binding. When the signal changes, the binding value is updated directly.
Expand Down