diff --git a/rfcs/0005-standard-signals.md b/rfcs/0005-standard-signals.md index 436d45d..80ab24b 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(() => { @@ -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.