From bcc51cd24e89133785c373984b1b09403d25810b Mon Sep 17 00:00:00 2001 From: Steve Orvell Date: Tue, 11 Mar 2025 16:24:37 -0700 Subject: [PATCH 1/2] decouple watch from reactive updates --- rfcs/0005-standard-signals.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rfcs/0005-standard-signals.md b/rfcs/0005-standard-signals.md index 436d45d..b0133d0 100644 --- a/rfcs/0005-standard-signals.md +++ b/rfcs/0005-standard-signals.md @@ -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(() => { From 797fa67141e3ecf835b04c21b3ac5228a093f6e5 Mon Sep 17 00:00:00 2001 From: Steve Orvell Date: Tue, 11 Mar 2025 16:33:15 -0700 Subject: [PATCH 2/2] Update 0005-standard-signals.md --- rfcs/0005-standard-signals.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rfcs/0005-standard-signals.md b/rfcs/0005-standard-signals.md index b0133d0..80ab24b 100644 --- a/rfcs/0005-standard-signals.md +++ b/rfcs/0005-standard-signals.md @@ -101,6 +101,10 @@ 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.