ng-sess-timeout
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

ng-sess-timeout

About

For implementing the session timeout login on front end. I have tried to keep it very simple but it will serve the purpose..

========

Authored by Naveen Shrinag mail- naveen.shrinag8787@gmail.com

Requirements

  • Angular 5 or later.

Getting Started (Example)

  1. installation : npm install ng-sess-timeout

  2. import NgTimeoutModule on your app.module.ts

    .... import {NgTimeoutModule} from 'ng-sess-timeout';

    @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, NgTimeoutModule, ... ], providers: [], bootstrap: [AppComponent] }) export class AppModule { }

  3. import {NgTimeout} from 'ng-sess-timeout'; // import to the component where you want to use this ....

    export class AppComponent {

     constructor(private sessTimer:NgTimeout) {
         
     }
    
     ngOnInit() {
    
         // set the session timeout time in minutes
         this.sessTimer.timer = 1;
    
         // subscribe to timeExpired to know if session has exprired. returns true (session expired) and false.
         this.sessTimer.timeExpired.subscribe((value)=> {
         console.log(value);
         })
    
         // suscribe to timeLeft to know how much time (in seconds) is left before session timeout
    
         this.sessTimer.timeLeft.subscribe((time)=> {
         console.log(time);
         })
    
         // to stop the timer but any user movement will again trigger it.
         this.sessTimer.stop(); 
    
         // use to reset the timer
    
         this.sessTimer.reset();
    
         // call to stop method on ngDestroy and unsubscribe, failing which can lead to unexpected errors.
     }
    

    }

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i ng-sess-timeout

    Weekly Downloads

    0

    Version

    0.0.2

    License

    none

    Unpacked Size

    81.6 kB

    Total Files

    26

    Last publish

    Collaborators

    • naveen8787