Methods

Methods are the API that is returned by IdleTimer. You can interface with your IdleTimer instance by using the following functions. Examples of how to use them can be found in the hook and higher order component docs.

start#


description

Resets the IdleTimer instance to its initial state and starts the timer. Returns a boolean denoting if the instance was started successfully.

type
() => boolean

reset#


description

Resets the IdleTimer instance to its initial state. Returns a boolean denoting if the instance was reset successfully.

type
() => boolean

activate#


description

Resets the IdleTimer instance to its initial state, restarting the timer, and emitting the onActive event if the user was idle or prompted. Returns a boolean denoting if the instance was activated successfully.

type
() => boolean

pause#


description

Pauses the IdleTimer instance. When paused all events are unbound. Returns a boolean denoting if the instance was paused successfully.

type
() => boolean

resume#


description

Resumes an IdleTimer instance from the time it was paused. When resumed, all events will be bound. Returns a boolean denoting if the instance was resumed successfully.

type
() => boolean

message#


description

Broadcast an arbitrary message to all instances of IdleTimer. If crossTab is enabled, all tabs will receive the message and their onMessage callback will be emitted. If emitOnSelf is set to true, the callee instance will also emit its onMessage callback. Returns a boolean denoting if the message was sent successfully.

type
(data: MessageType, emitOnSelf?: boolean) => boolean

isIdle#


description

Returns whether or not the user is idle.

type
() => boolean

isPrompted#


description

Returns whether or not the prompt is active.

type
() => boolean

isLeader#


description

Returns whether or not the current tab is the leader.

type
() => boolean

isLastActiveTab#


description

Returns whether or not the current tab is the last active tab.

type
() => boolean

getTabId#


description

Returns the current tabs id.

type
() => string

getRemainingTime#


description

Returns the number of milliseconds until idle.

type
() => number

getElapsedTime#


description

Returns the number of milliseconds since the hook was mounted.

type
() => number

getTotalElapsedTime#


description

Returns the number of milliseconds since the hook last reset.

type
() => number

getLastIdleTime#


description

Returns the last time the user was idle. Returns a Date instance that can be formatted.

type
() => Date | null

getLastActiveTime#


description

Returns the last time the user was active. Returns a Date instance that can be formatted.

type
() => Date | null

getIdleTime#


description

Returns the total time in milliseconds user has been idle since the last reset.

type
() => number

getTotalIdleTime#


description

Returns the total time in milliseconds user has been idle since the component mounted.

type
() => number

getActiveTime#


description

Returns the total time in milliseconds user has been active since the last reset.

type
() => number

getTotalActiveTime#


description

Returns the total time in milliseconds user has been active since the component mounted.

type
() => number

Made withby Randy Lebeau