From 53c770a764a60c6a9adca87a834b9590df0cc82b Mon Sep 17 00:00:00 2001 From: Shusui MOYATANI Date: Thu, 5 Oct 2023 02:14:35 +0900 Subject: [PATCH] fix: print stats if updated --- src/nostr/useStats.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/nostr/useStats.ts b/src/nostr/useStats.ts index c6ccfb5..ddae7ea 100644 --- a/src/nostr/useStats.ts +++ b/src/nostr/useStats.ts @@ -1,3 +1,5 @@ +import { createEffect, createRoot } from 'solid-js'; + import { createStore } from 'solid-js/store'; export type Stats = { @@ -10,9 +12,11 @@ const [stats, setStats] = createStore({ activeBatchSubscriptions: 0, }); -setInterval(() => { - console.debug('stats', { ...stats }); -}, 1000); +createRoot(() => { + createEffect(() => { + console.debug('stats', { ...stats }); + }); +}); const useStats = () => { const setActiveSubscriptions = (count: number) => setStats('activeSubscriptions', count);