@solid-primitives/idle
Advanced tools
Comparing version 0.0.100 to 0.0.101
@@ -44,4 +44,4 @@ import { Accessor } from 'solid-js'; | ||
*/ | ||
declare const createIdleTimer: ({ element, events, idleTimeout, promptTimeout, onActive, onIdle, onPrompt, startManually, }: IdleTimerOptions) => IdleTimerReturn; | ||
declare const createIdleTimer: ({ element, events, idleTimeout, promptTimeout, onActive, onIdle, onPrompt, startManually }?: IdleTimerOptions) => IdleTimerReturn; | ||
export { EventTypeName, IdleTimerOptions, IdleTimerReturn, createIdleTimer }; |
@@ -26,3 +26,3 @@ // src/createIdleTimer.ts | ||
startManually = false | ||
}) => { | ||
} = {}) => { | ||
let listenersAreOn = false; | ||
@@ -29,0 +29,0 @@ const [isPrompted, setIsPrompted] = createSignal(false); |
{ | ||
"name": "@solid-primitives/idle", | ||
"version": "0.0.100", | ||
"version": "0.0.101", | ||
"description": "A primitive to observe the user's idle status and react to its changes.", | ||
@@ -5,0 +5,0 @@ "author": "Aylo Srd <aylo.srd@gmail.com>", |
@@ -25,2 +25,3 @@ <p> | ||
## How to use it | ||
`createIdleTimer` provides different accessors and methods to observe the user's idle status and react to its changing. | ||
@@ -49,6 +50,10 @@ | ||
``` | ||
### Accessors and methods | ||
To interact with the timers, `createIdleTimer` provides: | ||
- **isIdle** and **isPrompted**: `Accessor<boolean>`; these two accessors report the user status. They do not concur. | ||
- **start**, **stop** and **reset**: `() => void`; allow rispectively to start and stop the timers, and to reset them. `start` and `reset`, create a custom `manualstart` and `manualreset` event, that will be passed to the `onIdle` and `onPrompt` callbacks if no oher activity occurs (there's another custom event, `mount`, created when timers start automatically). Finally `stop` and `reset` don't trigger `onActive`. | ||
### Configuration options | ||
@@ -71,3 +76,5 @@ | ||
Here is a working example: https://stackblitz.com/edit/vitejs-vite-dwxlhp?file=src/App.tsx | ||
## Acknowledgments | ||
This primitive is inspired by [react-idle-timer](https://idletimer.dev/) | ||
@@ -74,0 +81,0 @@ |
Sorry, the diff of this file is not supported yet
19323
82