idle-detector
Version:
[Description:] This library is created to detect the Inactivity of the User. You can specify the Inactivity [timeout] in [milliseconds].
44 lines (38 loc) • 1.48 kB
Markdown
# IdleDetector
[Description:]
This library is created to detect the Inactivity of the User.
You can specify the Inactivity [timeout] in [milliseconds].
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.3.0.
## How to use:
1.Run `npm i idle-detector@latest` or `npm install idle-detector@latest`
2.In you project Module file `app.module.ts` import `IdleDetectorModule`
```ts
//import the idle-detector as follows
import {IdleDetectorModule } from 'idle-detector';
```
3.Then add `IdleDetectorModule` in the `imports:[]` of your `app.module.ts`
```ts
//import the idle-detector as follows
@NgModule({
declarations: [
AppComponent,
],
imports: [
IdleDetectorModule,
],
providers: [],
bootstrap: [AppComponent]
})
```
4.Then in the root component 'app.component.html' file add the Directive,Input and output as follow
For Example consider my `app.component.html` has a div element as a parent element
```shell
<div libIdleDetector [timeout]="5000" (timedOut)="logOut($event)" >
..........
..........
</div>
```
In the above code
* `libIdleDetector` - is a directive
* `timeout` - Input to the directive which specifies the inactivity duration in `milliseconds`
* `timedOut` - Output from the directive which calls the function after the inactivity duration, here `logOut($event)` function is called and in the `$event` the `true` value will be coming,this `logOut($event)` will be in the `app.component.ts` file.