getLastChanged

Category Reactivity

Get the last time the reactive value changed. It is returned as a number in milliseconds.

Demo

Value : 0 Value last changed : 01.01.1970 00:00:00

Usage

<script>
	import { getLastChanged } from '@sv-use/core';
 
	let value = $state(0);
	const lastChanged = getLastChanged(() => value);
</script>
Type definitions
/**
 * 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/reactivity/get-last-changed
 */
export declare function getLastChanged<T>(value: () => T): {
    readonly current: number;
};

Sources