ng-timeout
This is the version-agnostic project for https://github.com/jackjamieson/ng2-timeout
I will not be updating ng2-timeout although in my testing it was working up to Angular 7. This project is recreated in Angular's new library generation and will be much easier to update and maintain.
Creates observables for user idle and timeout with manual interrupts. Detects interrupts across browser tabs with storage-emitter.
Installation
To install this library, run:
$ npm install ng-timeout storage-emitter --save
Consuming library
Import library in any Angular application from your Angular AppModule
:
// Import library;
To use the module I recommend injecting the service into your top level app component.
From there you can control what causes interrruptions to the timers and how you want to handle idle or timeout.
; private idleState: string; // if you want to show the countdown for example constructor private timeoutService: NgTimeoutService
Here is an example @HostListener
for detecting keypress
handleKeyboardEventevent: KeyboardEvent
Development
The parent Angular project is included with this so it should be easy to set up and update. Follow Angular's guide on creating libraries.
- npm install
- edit projects/ng-timeout
- ng build ng-timeout
- output is in the dist folder
License
MIT © Jack Jamieson