Skip to content

Angular (4.x+) directive to handle user inactivity which is very helpful especially in validated projects

License

Notifications You must be signed in to change notification settings

chuckmah/ngx-inactivity

 
 

Repository files navigation

ngx-inactivity

Angular (4.x+) directive to handle user inactivity. Very helpful especially in validated projects.

Installation

Using NPM:

npm install ngx-inactivity --save

Requirements

Usage

In your app.module file:

import { NgxInactivity } from 'ngx-inactivity';

@NgModule({
  ...
  imports: [
    NgxInactivity
  ]
  ...
})

In your app.component.html file:

<div class="app" (ngxInactivityCallback)="handleInactivityCallback()">

In your app.component.ts file

export class AppComponent {

  /**
   * Handle inactivity callback
   */
  public handleInactivityCallback() {
    // Sign out current user or display specific message regarding inactivity
  }
}

Options

  • [ngxInactivity] - inactivity timeout in minutes (15 minutes by defualt)
  • (ngxInactivityInterval) - inactivity time interval in mili seconds (1000 ms by default)
  • [ngxInactivityCallback] - event emitter to handle inactivity callback

Examples

  • Add callback "handleUserInactivity" after 10 minutes of user's inactivity (no mouse moves, clicks or keypresses):
<div
  [ngxInactivity]="10"
  (ngxInactivityCallback)="handleUserInactivity()">
  Application template..
</div>

About

Angular (4.x+) directive to handle user inactivity which is very helpful especially in validated projects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 82.9%
  • JavaScript 13.4%
  • HTML 3.7%