how to check user is active on page in Angular 2 -


how can check mouse , key events in angular 2 globally, meant @ root level. want call 1 service when user interacting not idle application. please me , suggest solution on this.

in top level component, create observable event of document object , invoke service, example:

import 'rxjs/add/observable/fromevent'; import {observable} "rxjs/observable"; ...  const clicks$ = observable.fromevent(document, 'click'); clicks$.subscribe(x => console.log('calling service here')); 

Comments

Popular posts from this blog

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -