UNPKG

@sv-use/core

Version:

A collection of Svelte 5 utilities.

9 lines (8 loc) 285 B
import { watch } from '../watch/index.svelte.js'; export function getPrevious(getter, initial = undefined) { const _previous = $state({ current: initial }); watch(() => $state.snapshot(getter()), (_, prev) => { _previous.current = prev; }); return _previous; }