From 61c87ee50aeb68cbabe56a51f34a3f0aa4302057 Mon Sep 17 00:00:00 2001 From: Bryan Terce Date: Tue, 25 Jun 2019 11:27:21 -0700 Subject: [PATCH 1/2] Fix docs typo with derived store --- site/content/docs/03-run-time.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/content/docs/03-run-time.md b/site/content/docs/03-run-time.md index 6db20b5d14..0a8bf9843d 100644 --- a/site/content/docs/03-run-time.md +++ b/site/content/docs/03-run-time.md @@ -365,7 +365,7 @@ If you return a function from the callback, it will be called when a) the callba import { derived } from 'svelte/store'; const tick = derived(frequency, ($frequency, set) => { - const interval = setInterval(() => set(Date.now()), 1000 / frequency); + const interval = setInterval(() => set(Date.now()), 1000 / $frequency); return () => { clearInterval(interval); From 77c8e15f72f61d49ebb4f5f3692fdb0cce7308cb Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 25 Jun 2019 19:38:32 -0400 Subject: [PATCH 2/2] Update 03-run-time.md --- site/content/docs/03-run-time.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/site/content/docs/03-run-time.md b/site/content/docs/03-run-time.md index 0a8bf9843d..bd5d4b40ce 100644 --- a/site/content/docs/03-run-time.md +++ b/site/content/docs/03-run-time.md @@ -359,17 +359,21 @@ const delayed = derived(a, ($a, set) => { }, 'one moment...'); ``` -If you return a function from the callback, it will be called when a) the callback runs again, or b) the last subscriber unsubscribes: +--- + +If you return a function from the callback, it will be called when a) the callback runs again, or b) the last subscriber unsubscribes. ```js import { derived } from 'svelte/store'; const tick = derived(frequency, ($frequency, set) => { - const interval = setInterval(() => set(Date.now()), 1000 / $frequency); + const interval = setInterval(() => { + set(Date.now()); + }, 1000 / $frequency); return () => { clearInterval(interval); - } + }; }, 'one moment...'); ```