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

@ng-idle does not work with Angular 8 #133

Closed vamcs closed 4 years ago

vamcs commented 4 years ago

Describe the bug No observable is ever triggered, and the extension simply can't be used.

To Reproduce Create an Angular 8 project and implement the example project.

In app.module.ts I provided the service with NgIdleModule.forRoot() in the imports array. And this is the constructor of app.component.ts:

constructor(private idle: Idle) {
    this.idle.setIdle(5);
    this.idle.setTimeout(5);
    this.idle.setInterrupts(DEFAULT_INTERRUPTSOURCES);
    this.idle.onIdleStart.subscribe(() => console.log('Gone idle'));
    this.idle.onIdleEnd.subscribe(() => console.log('Idle no more'));
    this.idle.onTimeoutWarning.subscribe((countdown: number) =>
      console.log(
        `You'll be logged out in ${countdown} seconds because of inactivity.`
      )
    );
    this.idle.onTimeout.subscribe(() => console.log('Timeout'));
  }

Expected behavior The extension would work at all.

Please tell us about your environment

vamcs commented 4 years ago

Of course, the problem was simple. I forgot to call idle.watch() to tell the extension to start running.