ng-inactivity-timer
Description
ng-inactivity-timer provides a service that keeps track of user activity based on custom activity monitors.
Installation
Install the package by running
npm install ng-inactivity-timer
Usage
Provide a configuration for the service (numbers are in seconds):
Create a custom activity monitor:
Provide the monitor:
Inject the inactivity service
Using the service
// Start monitoring// if called with true, will also trigger actvivitythis.inactivityTimerService.startMonitor; // Stop monitoringthis.inactivityTimerService.stopMonitor; // Get an observable emitting Timout objects describing the activity statusthis.inactivityTimerService.getTimeOut.subscribe; // Trigger an activity (other than the ones provided by the monitor)this.inactivityTimerService.activate;
Using the Timout objects
The getTimeOut()
function emits objects of the Timeout interface: