idle-detect
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

Idle Detect

A TypeScript library for inactivity timer, which utilises IdleDetector API where possible or a fallback to window.setTimeout approach.

Usage

npm install idle-detect
import IdleDetect from 'idle-detect'
// Or, if you don't want to use still experimental IdleDetector API:
// import { IdleDetect } from 'idle-detect/dist/IdleDetect'

const onInactive = () => {
  console.info('User is inactive now')
}
const idleDetect = new IdleDetect(15 * 60, onInactive)

// Start timer, e.g. when user is logged in
idleDetect.start()

// End timer, e.g. when user is logged out
idleDetect.cleanupAndStop()

Package Sidebar

Install

npm i idle-detect

Weekly Downloads

170

Version

0.2.0

License

MIT

Unpacked Size

26.5 kB

Total Files

12

Last publish

Collaborators

  • dmythro