import { readable } from 'svelte/store';

// A single 60-second clock shared by every component that renders a relative
// timestamp ("vor 5 Min."). One interval for the whole app — not one per card —
// so a 1000-item feed stays cheap, and the interval is torn down automatically
// when the last subscriber unsubscribes.
export const now = readable(Date.now(), (set) => {
	const id = setInterval(() => set(Date.now()), 60_000);
	return () => clearInterval(id);
});
