SupremeTechnopriest/react-idle-timer

View on GitHub
docs/pages/docs/api/methods.mdx

Summary

Maintainability
Test Coverage
---
title: Methods
description: IdleTimer 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](/docs/api/use-idle-timer)
and [higher order component](/docs/api/with-idle-timer) docs.

### start
<Property
  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
<Property
  description='Resets the IdleTimer instance to its initial state. Returns a boolean denoting if the instance was reset successfully.'
  type='() => boolean'
/>

### activate
<Property
  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
<Property
  description='Pauses the IdleTimer instance. When paused all events are unbound. Returns a boolean denoting if the instance was paused successfully.'
  type='() => boolean'
/>

### resume
<Property
  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
<Property
  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
<Property
  description='Returns whether or not the user is idle.'
  type='() => boolean'
/>

### isPrompted
<Property
  description='Returns whether or not the prompt is active.'
  type='() => boolean'
/>

### isLeader
<Property
  description='Returns whether or not the current tab is the leader.'
  type='() => boolean'
/>

### isLastActiveTab
<Property
  description='Returns whether or not the current tab is the last active tab.'
  type='() => boolean'
/>

### getTabId
<Property
  description='Returns the current tabs id.'
  type='() => string'
/>

### getRemainingTime
<Property
  description='Returns the number of milliseconds until idle.'
  type='() => number'
/>

### getElapsedTime
<Property
  description='Returns the number of milliseconds since the hook was mounted.'
  type='() => number'
/>

### getTotalElapsedTime
<Property
  description='Returns the number of milliseconds since the hook last reset.'
  type='() => number'
/>

### getLastIdleTime
<Property
  description='Returns the last time the user was idle. Returns a Date instance that can be formatted.'
  type='() => Date | null'
/>

### getLastActiveTime
<Property
  description='Returns the last time the user was active. Returns a Date instance that can be formatted.'
  type='() => Date | null'
/>

### getIdleTime
<Property
  description='Returns the total time in milliseconds user has been idle since the last reset.'
  type='() => number'
/>

### getTotalIdleTime
<Property
  description='Returns the total time in milliseconds user has been idle since the component mounted.'
  type='() => number'
/>

### getActiveTime
<Property
  description='Returns the total time in milliseconds user has been active since the last reset.'
  type='() => number'
/>

### getTotalActiveTime
<Property
  description='Returns the total time in milliseconds user has been active since the component mounted.'
  type='() => number'
/>