I am able to detect the user idle time using simple mouse and key event.as below.

@HostListener('window:keydown', ['$event'])
@HostListener('window:mousedown', ['$event'])
@HostListener('window:mousewheel', ['$event'])
refreshUserState() {`enter code here`
 clearTimeout(this.userActivity);
 this.setTimeout();
}

is this will cause any performance issue and advantage of using ng-idle over this approach?

1

There are 1 best solutions below

0
Flo On BEST ANSWER

ng-idle has a lot of events and timers to handle and detect if user idle. It depends on your project and requirements if you need `ng-idle*.

In the end you can handle it with your code sample. But only mouse events/keyboard events can be not enough to detect each situation (think about mobile devices/touch).

But in the end: You basically don't have performance issues if you use your code instead of ng-idle