Ng Idle pauses when system goes to sleep mode
Opened this issue ยท 9 comments
I have used Ng Idle version 6.0.0-beta.3 and using angular 6, this library is working fine system is on but timer stops when system goes to sleep mode. How to achieve idle state is system goes to sleep?
I'm experiencing a similar issue with the system going to sleep. idle occurs, laptop sleeps, laptop wakes and then onIdleEnd does not fire.
To duplicate:
1 - Set my idle timer at 5 seconds.
2 - onIdleStart does a console.log, see the output
3 - Widows / sleep
4 - wake
5 - Move mouse on browser and onIdleEnd does not fire.
after waking idle.isRunning() = false.
Ok, so immediately after posting my issue with onIdleEnd I figured out my mistake. If I didn't post, I'd have never figured it out. There is a timeout after onIdleStart that defaults to 30 seconds.
I added this line and things are working fine now.
this.idle.setTimeout(false);
I also tested a sleep for the idle to fire:
1 - set 60 second timer
2 - windows / sleep
3 - wake
4 - my console.log output for idle was there.
This particular timer is using SimpleExpiry. I've not tested this use case with IdleExpiry.
@earbullet can you indicate where you added this line of code?
@earbullet what is the actual solution for this issue ?
constructor(@Inject('GlobalIdle') private _idle: Idle)
....
const documnetInterruptsOnly = DEFAULT_INTERRUPTSOURCES.slice(0, 1);
this._idle.setInterrupts(documnetInterruptsOnly);
this._idle.onIdleEnd.subscribe(() => {
....
});
this._idle.onIdleStart.subscribe(() => {
....
});
this._idle.setTimeout(false); // this is the line that I was missing
this._idle.watch();
constructor(@Inject('GlobalIdle') private _idle: Idle) .... const documnetInterruptsOnly = DEFAULT_INTERRUPTSOURCES.slice(0, 1); this._idle.setInterrupts(documnetInterruptsOnly); this._idle.onIdleEnd.subscribe(() => { .... }); this._idle.onIdleStart.subscribe(() => { .... }); this._idle.setTimeout(false); // this is the line that I was missing this._idle.watch();
Does not works on Mac!
Any idea or fix?
This is not a solution to the problem, this only disables the timeout function.
I want to use the idle and timeout function, and that it takes into account if the user shutdown or put to sleep the computer.