@sv-use/core
Version:
A collection of Svelte 5 utilities.
18 lines (17 loc) • 423 B
JavaScript
/**
* Get the last time a state changed.
* @param value The state to track as a getter function.
* @see https://svelte-librarian.github.io/sv-use/docs/core/get-last-changed
*/
export function getLastChanged(value) {
let _lastChanged = $state(0);
$effect(() => {
value();
_lastChanged = Date.now();
});
return {
get current() {
return _lastChanged;
}
};
}