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(useTimeoutFn): respect callback parameters in start function #2693

Merged
merged 1 commit into from Jan 29, 2023

Conversation

wvffle
Copy link
Contributor

@wvffle wvffle commented Jan 28, 2023

Description

fixes #2691

Additional context

On L62 of useTimeoutFn, start() is used without any parameters. What if user defines a callback that requires arguments to work? Maybe a new option like defaultArguments could be introduced?


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@antfu antfu merged commit e054a24 into vueuse:main Jan 29, 2023
@wvffle wvffle deleted the wvffle/fix-2691 branch January 29, 2023 11:19
@wvffle
Copy link
Contributor Author

wvffle commented Jan 29, 2023

@antfu what's your view on the additional context provided in the PR description?

Provided:

const { start } = useTimeoutFn((arg1: string, arg2: number) =>{
  // ...
})

Due to explicitly added [] to the Stoppable type users can do start() without arguments even though they're required.

I've added it explicitly to allow for immediate start. Maybe there should be an option for the arguments passed to the immediate start call?

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.

start function of Stoppable doesn't receive arguments
2 participants