From 752d791474343fc3090feb6cb42bc2a7d0cc347b Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sun, 31 Jan 2021 15:28:01 +0800 Subject: [PATCH] fix(useTimeoutFn): immediate on SSR, close #317 --- packages/shared/ignorableWatch/index.md | 6 +++--- packages/shared/useTimeoutFn/index.ts | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/shared/ignorableWatch/index.md b/packages/shared/ignorableWatch/index.md index bd9d8d20d3e8..120f9a25108c 100644 --- a/packages/shared/ignorableWatch/index.md +++ b/packages/shared/ignorableWatch/index.md @@ -24,7 +24,7 @@ const { stop, ignoreUpdates } = ignorableWatch( source.value = 'bar' await nextTick() // logs: Changed to bar! -ignoreUpdates( () => { +ignoreUpdates(() => { source.value = 'foobar' }) await nextTick() // (nothing happened) @@ -32,7 +32,7 @@ await nextTick() // (nothing happened) source.value = 'hello' await nextTick() // logs: Changed to hello! -ignoreUpdates( () => { +ignoreUpdates(() => { source.value = 'ignored' }) source.value = 'logged' @@ -64,7 +64,7 @@ source.value = 'bar' await nextTick() // logs: Changed to bar! source.value = 'good' -source.value = 'bye' +source.value = 'by' ignorePrevAsyncUpdates() await nextTick() // (nothing happened) diff --git a/packages/shared/useTimeoutFn/index.ts b/packages/shared/useTimeoutFn/index.ts index c306368ab5e7..56915fc56e85 100644 --- a/packages/shared/useTimeoutFn/index.ts +++ b/packages/shared/useTimeoutFn/index.ts @@ -52,8 +52,11 @@ export function useTimeoutFn( }, interval) } - if (immediate && isClient) - start() + if (immediate) { + isPending.value = true + if (isClient) + start() + } tryOnUnmounted(stop)