Open santanu-biswas opened 7 years ago
We have a similar problem here, some updates about that @santanu-biswas ? Did you solve it? How?
Try following, this worked for me:
this.subscriptionOnIdleStart = this.idle.onIdleStart.subscribe(() => { this.idleState = 'You\'ve gone idle!'; Logger.log('onIdleStart') });
ngOnDestroy(): any { this.subscriptionOnIdleStart.unsubscribe(); }
Adding this.idle.stop()
to ngOnDestroy()
worked for me (adding the unsubscribe
didn't change anything), here's the original Plunker working fine after the addition of this.idle.stop()
:
Still getting the same error ,, on next screen or route change,, the interrupts events are not working, didn't get any interrupt even if trying to call this.idle.setInterrupts(DEFAULT_INTERRUPTSOURCES);
and this cause idle to start subscribing and showing . Please comment @HackedByChinese @rgoj @vincent-cm
I had also faced the same issue when I was implementing it on my project, to resolve it, I removed "this.idle.watch();" from reset() function and place it below idle.setInterrupts(DEFAULT_INTERRUPTSOURCES); inside constructor.
I'm submitting a ... (check one with "x")
Current behavior I have two routes at app root level - login (LoginComponent) and content (ContentComponent).
Only content component has
ng2-idle
configured in its constructor.On first entry/visit to content view everything works fine.
However, if I go to logout (or any other view) and come back to content, the interrupts are not detected by
ng2-idle
andonIdleStart
gets triggered after the timeout period! Even after that no matter how much I click on the screen or scroll etc, theonIdleEnd
event is not triggered andonIdleTimeout
gets triggered. After that everything again starts works well.Expected behavior
ng2-idle should work consistently on first visit or subsequent visits to the route
Minimal reproduction of the problem with instructions
Please visit the following Plunk to check the bug: https://plnkr.co/edit/OHhNJHYrmx0oWkIqYq7V?p=preview
What is the motivation / use case for changing the behavior?
Idle timeout is used only for protected content. It is never used for login page.
Please tell us about your environment:
OSx (macOS Sierra) VSCode NPM Node.js
@ng-idle version: 2.x
latest
Angular version: 2.x
2.4.4
Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
Checked on Chrome, Safari & Firefox
Language: [all | TypeScript X.X | ES6/7 | ES5] Typescript
Node:
node --version
= 7.4.0