diff options
| author | Fuwn <[email protected]> | 2026-03-01 14:20:08 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-03-01 15:24:03 -0800 |
| commit | 3b10a1f47fd5838fe3b94c19673a52610b88cf1e (patch) | |
| tree | d468a1fc12290e38686b255194ff6596b58cbf01 /src/stores/airingNow.ts | |
| parent | perf(match): fast-path exact normalised title matches (diff) | |
| download | due.moe-3b10a1f47fd5838fe3b94c19673a52610b88cf1e.tar.xz due.moe-3b10a1f47fd5838fe3b94c19673a52610b88cf1e.zip | |
perf: optimise list hot paths and shared timers
Diffstat (limited to 'src/stores/airingNow.ts')
| -rw-r--r-- | src/stores/airingNow.ts | 14 |
1 files changed, 14 insertions, 0 deletions
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; |