Skip to content

Commit

Permalink
fix(useTimeoutPoll): immediate default value should be true (#4232)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Fu <[email protected]>
  • Loading branch information
phk422 and antfu authored Jan 2, 2025
1 parent 302be9a commit 0450d82
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/core/useTimeoutPoll/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ import type { Awaitable, MaybeRefOrGetter, Pausable, UseTimeoutFnOptions } from
import { tryOnScopeDispose, useTimeoutFn } from '@vueuse/shared'
import { ref } from 'vue'

export function useTimeoutPoll(fn: () => Awaitable<void>, interval: MaybeRefOrGetter<number>, timeoutPollOptions?: UseTimeoutFnOptions): Pausable {
export function useTimeoutPoll(
fn: () => Awaitable<void>,
interval: MaybeRefOrGetter<number>,
options: UseTimeoutFnOptions = {},
): Pausable {
const {
immediate = true,
} = options

const { start } = useTimeoutFn(loop, interval, { immediate: false })

const isActive = ref(false)
Expand All @@ -26,7 +34,7 @@ export function useTimeoutPoll(fn: () => Awaitable<void>, interval: MaybeRefOrGe
isActive.value = false
}

if (timeoutPollOptions?.immediate)
if (immediate)
resume()

tryOnScopeDispose(pause)
Expand Down

0 comments on commit 0450d82

Please sign in to comment.