Idle Detection
As its namesake suggests, idle detection is the flagship feature of IdleTimer. The idle detection feature set is responsible for tracking your users activity based on the events you want to listen to and let you know when the user has not triggered those events in a given time period.
Properties#
The properties associated with idle detection are:
- timeout: The time before a user is considered idle.
- element: The DOM element to bind event listeners to.
- events: The events to listen for activity on.
- immediateEvents: The events that will immediately trigger an idle event (bypassing timeout).
- onPresenceChange: Function called when a user's presence state changes.
- onIdle: Function called when a user becomes idle from an active state.
- onActive: Function called when a user becomes active from an idle state.
- eventsThrottle: Throttle for the events bound. Saves on CPU if you are using repeated events.
- startOnMount: Starts the timer when the host component mounts.
- startManually: Require a call to
start()
in order to start the timer. - stopOnIdle: Require the timer to be manually reset after going idle by calling
start()
orreset()
.
Methods#
The methods associated with idle detection are:
- start: Starts the timer.
- reset: Resets the timer to its initial state.
- activate: Resets the IdleTimer instance to its initial state, starts the timer and emits
onActive
if the user was idle. - pause: Pauses a running timer.
- resume: Resumes a running timer.
- getElapsedTime: Returns the time in milliseconds since the host component was mounted.
- getRemainingTime: Returns the time remaining in milliseconds until idle.
- getLastActiveTime: Returns a Date of the last time the user was active.
- getActiveTime: Returns time in milliseconds the user was active since the last reset.
- getTotalActiveTime: Returns time in milliseconds the user was active since the component mounted.
- getLastIdleTime: Returns a Date of the last time the user was idle.
- getIdleTime: Returns time in milliseconds the user was idle since the last reset.
- getTotalIdleTime: Returns time in milliseconds the user was idle since the component mounted.