Skip to content

Commit

Permalink
fix(useTimeoutFn): immediate on SSR, close vitest-dev#317
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jan 31, 2021
1 parent dbc0959 commit 752d791
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/shared/ignorableWatch/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ const { stop, ignoreUpdates } = ignorableWatch(
source.value = 'bar'
await nextTick() // logs: Changed to bar!

ignoreUpdates( () => {
ignoreUpdates(() => {
source.value = 'foobar'
})
await nextTick() // (nothing happened)

source.value = 'hello'
await nextTick() // logs: Changed to hello!

ignoreUpdates( () => {
ignoreUpdates(() => {
source.value = 'ignored'
})
source.value = 'logged'
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions packages/shared/useTimeoutFn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ export function useTimeoutFn(
}, interval)
}

if (immediate && isClient)
start()
if (immediate) {
isPending.value = true
if (isClient)
start()
}

tryOnUnmounted(stop)

Expand Down

0 comments on commit 752d791

Please sign in to comment.