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

Need a timeout setting for the state is changing from Idle to Active #348

Open
alexya opened this issue May 31, 2023 · 0 comments
Open

Need a timeout setting for the state is changing from Idle to Active #348

alexya opened this issue May 31, 2023 · 0 comments
Labels
enhancement A new feature or improvement to an existing feature. triage Has not been reviewed yet and should not be worked on.

Comments

@alexya
Copy link

alexya commented May 31, 2023

Feature Information

Is your feature request related to a problem? Please describe.

  const { getRemainingTime } = useIdleTimer({
    onIdle,
    onActive,
    onAction,
    timeout: 10_000, // timeout setting when state changing from `Active` to `Idle`
    throttle: 1500
  })

We will develop a web app that will charge the money from our customers according to the app usage time.

When the user starts to use the app, we charge the money. When the app is idle, it means that the user is leaving the browser/computer, etc., so we will not charge the money. And then when the app is active, it means that the user is back, and we will continue to start charging the money.

But the problem is that, when the user is back, the state is changing from idle to active immediately, and there is no cache. If the user just goes back to the tab and wants to close it, it will still trigger the onActive, and the user will be charged the money.

Describe the solution you'd like.

if the state is changing from Active to 'Idle, there is a timeout setting and getRemainingTime API for use, I wonder if you can add an optional parameter, a similar timeout setting, and API for the state changing from idle` to 'Active'.

Describe alternatives you've considered.

Now, we have to use an additional code, e.g. setTimeout, to handle this scenario.

Additional context.

Add any other context or screenshots about the feature request here.

@alexya alexya added enhancement A new feature or improvement to an existing feature. triage Has not been reviewed yet and should not be worked on. labels May 31, 2023
@alexya alexya changed the title Need a timeout setting for the state is changing from 'Idle' to 'Active' Need a timeout setting for the state is changing from Idle to Active May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature or improvement to an existing feature. triage Has not been reviewed yet and should not be worked on.
Projects
None yet
Development

No branches or pull requests

1 participant