From 3b10a1f47fd5838fe3b94c19673a52610b88cf1e Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 1 Mar 2026 14:20:08 -0800 Subject: perf: optimise list hot paths and shared timers --- src/stores/airingNow.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/stores/airingNow.ts (limited to 'src/stores/airingNow.ts') diff --git a/src/stores/airingNow.ts b/src/stores/airingNow.ts new file mode 100644 index 00000000..697001ef --- /dev/null +++ b/src/stores/airingNow.ts @@ -0,0 +1,14 @@ +import { browser } from '$app/environment'; +import { readable } from 'svelte/store'; + +const TICK_INTERVAL_MS = 30 * 1000; + +const airingNow = readable(Date.now(), (set) => { + if (!browser) return () => undefined; + + const interval = setInterval(() => set(Date.now()), TICK_INTERVAL_MS); + + return () => clearInterval(interval); +}); + +export default airingNow; -- cgit v1.2.3