moribvndvs / ng2-idle

Responding to idle users in Angular (not AngularJS) applications.
https://moribvndvs.github.io/ng2-idle
Apache License 2.0
315 stars 128 forks source link

How to get/watch the multiple multiple instances of ng2-idle #117

Open Brunnik opened 5 years ago

Brunnik commented 5 years ago

Hi all, I want to create the multiple instances of ng2-idle in my application, one is for idle-logout after 10 mins and another is for auto saving the inputs if the application idle for 10 seconds. Right now I had created multiple instances(using setIdleName) for this case, but the timeout is happening on the last idle time I had set. Please help me to solve this issue

lapongua commented 5 years ago

It happens the same to me. have you solved it?

constructor(private idle: Idle,  private idle2: Idle){
idle.setIdle(1000);     // sets an idle timeout of "environment.idle_time" seconds
    idle.setTimeout(5); // sets a timeout period of "environment.timeout_time" seconds
    idle.setInterrupts(DEFAULT_INTERRUPTSOURCES); // sets the default interrupts, in this case, things like clicks, scrolls, touches to the document
    idle.setIdleName('main');

    idle2.setIdle(15);
    idle2.setTimeout(5);
    idle2.setIdleName('notifications');

console.log(this.idle.getIdle()); // Output 15
console.log(this.idle2.getIdle()); // Output 15
}