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

Manual Trigger of events bypassing Timeout. #297

Open
YasarArafathAli opened this issue Nov 9, 2022 · 2 comments
Open

Manual Trigger of events bypassing Timeout. #297

YasarArafathAli opened this issue Nov 9, 2022 · 2 comments
Labels
awaiting response Requires additional context or information. enhancement A new feature or improvement to an existing feature.

Comments

@YasarArafathAli
Copy link

Feature Information

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

I was working on a use case where the user FocusOuts from an editor, i want the idletimer to trigger onIdle event.

Describe the solution you'd like.

add a method to trigger events provided in the init of idle timer

@YasarArafathAli YasarArafathAli added enhancement A new feature or improvement to an existing feature. triage Has not been reviewed yet and should not be worked on. labels Nov 9, 2022
@SupremeTechnopriest
Copy link
Owner

SupremeTechnopriest commented Nov 9, 2022

Have you checked out the [immediateEvents](https://idletimer.dev/docs/api/props#immediateevents) option? That might work for you.

Otherwise, what is stopping you from just calling your onIdle function? Something like:

const elementRef = useRef()

const onIdle = () => {
  if (!isIdle()) pause()
  // Do other stuff
}

const { isIdle, pause } = useIdleTimer({
  onIdle
})

useEffect(() => {
  elementRef.current.addEventListener('blur', handleIdle)
  return () => {
    elementRef.current.removeEventListener('blur', handleIdle)
  }
}, [])

@SupremeTechnopriest
Copy link
Owner

@YasarArafathAli

Just checking to see if this is still an issue for you. Would like to understand the use case a little better to craft the best solution.

@SupremeTechnopriest SupremeTechnopriest added awaiting response Requires additional context or information. and removed triage Has not been reviewed yet and should not be worked on. labels Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response Requires additional context or information. enhancement A new feature or improvement to an existing feature.
Projects
None yet
Development

No branches or pull requests

2 participants