Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(useIntervalFn): watch computed refs instead of just refs #2539

Merged
merged 1 commit into from Dec 16, 2022
Merged

fix(useIntervalFn): watch computed refs instead of just refs #2539

merged 1 commit into from Dec 16, 2022

Conversation

innocenzi
Copy link
Contributor

useIntervalFn's interval option has the ability to be watched to dynamically change the interval. However, the check to add the watcher uses isRef, even though interval is of type MaybeComputedRef, which allows it to be a function, which is a valid watch value.

This pull request changes the check to ensure interval is either a Ref or a Function, so the following is also valid:

const $props = defineProps<{
  interval?: number
}>()

useIntervalFn(() => { /** ... **/ }, () => $props.interval ?? 5000)

@innocenzi
Copy link
Contributor Author

CI fails but the errors seem to be unrelated to this PR

@antfu antfu merged commit 8bb7b50 into vueuse:main Dec 16, 2022
@innocenzi innocenzi deleted the fix/interval-fn-ref branch December 16, 2022 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants