Skip to content

Watchers ​

Sprig does not have a separate watch() API. Use effect(fn) when side effects should rerun for the signals or store properties read during execution:

js
import { effect, signal } from 'sprig-framework';

const [query, setQuery] = signal('sprig');
const stop = effect(() => console.log('search:', query()));
setQuery('signals');
stop();

Effects run immediately, refresh their dependencies on each execution, and return a stop function. createRoot() scopes effects and cleanup; onCleanup() registers teardown work. There is no separate old/new-value watcher or flush-mode API.