From d8d86c02e14fa7f2c7ef546ef1166671c0c46554 Mon Sep 17 00:00:00 2001 From: Dmytro Klymenko Date: Mon, 10 Jan 2022 13:53:37 +0200 Subject: [PATCH] feat: update constructor & code example --- README.md | 2 ++ package.json | 2 +- src/IdleDetectIsomorph.ts | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b85f3ed..fbea120 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ npm install idle-detect ```ts 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') diff --git a/package.json b/package.json index a3876b2..292b838 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "idle-detect", - "version": "0.1.0", + "version": "0.1.1", "description": "A TypeScript library for inactivity timer, which utilises `IdleDetector` API where possible or a fallback to `window.setTimeout` approach", "main": "dist/index.js", "scripts": { diff --git a/src/IdleDetectIsomorph.ts b/src/IdleDetectIsomorph.ts index 7b295ef..193ee61 100644 --- a/src/IdleDetectIsomorph.ts +++ b/src/IdleDetectIsomorph.ts @@ -1,4 +1,4 @@ -import { IdleDetect, defaultEventTypes, defaultNoop } from './IdleDetect' +import { IdleDetect, defaultEventTypes, defaultIdleTime, defaultNoop } from './IdleDetect' export const isIdleDetectorSupported = () => 'IdleDetector' in window @@ -9,7 +9,7 @@ export class IdleDetectIsomorph extends IdleDetect { constructor( /** Number of seconds for idle detection, 15 minutes by default */ - idleSeconds: number, + idleSeconds: number = defaultIdleTime, /** Event handler when user is idle for specified time */ onIdle: () => void = defaultNoop, enableLogs = false,