question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clear and concise description of the problem

It would be helpful to have a timer composable that would execute a callback after it’s finished, something like useTimer from React, and if it sounds cool I could work on a PR asap.

Suggested solution

Usage would be like:

  const { timer, start } = useTimer(5, () => {
    isButtonDisabled.value = false;
  });

I’ve created a stackblitz initial implementation with some controls, but the API could be simpler.

Alternative

No response

Additional context

No response

Validations

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
franciscoemanuelcommented, Nov 12, 2022

@chaii3 for sure, I will draft something as soon as I can

1reaction
Zehircommented, Oct 3, 2022

So with coundown and countup option ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

use-timer - npm
A timer hook for React. Latest version: 2.0.1, last published: 2 years ago. Start using use-timer in your project by running `npm i ......
Read more >
thibaultboursier/use-timer: A timer hook for React - GitHub
Simple timer turned into React Hooks. Read about Hooks feature. Installation. npm i use-timer.
Read more >
useTimer - react-timer-hook - CodeSandbox
CodeSandbox is an online editor tailored for web applications.
Read more >
Develop a Custom useTimer Hook in React
A small example to create a custom useTimer Hook for React Applications to responsibly get around the mischievous setInterval function.
Read more >
Invalid hook call when calling useTimer() inside useEffect ...
Hooks must not be called into javascript function which are not a function component or a custom hook. Note that hooks only works...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found