@jsvision/ui / effect
Function: effect()
effect(
fn):void
Defined in: ui/src/reactive/effect.ts:33
Register a reactive side effect and run it once immediately. It re-runs on every change to a signal or computed it read, and is disposed with its owner scope.
Parameters
fn
() => void
The effect body; the signals/computeds it reads become its dependencies (re-collected on each run, so conditional branches only subscribe what they actually read).
Returns
void
Example
ts
import { signal, effect, createRoot } from '@jsvision/ui';
const name = signal('Ada');
createRoot((dispose) => {
effect(() => console.log('hello', name())); // "hello Ada", then re-runs on change
name.set('Grace'); // "hello Grace"
dispose(); // effect stops re-running
});