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

Type Error: Cannot read property 'getTime' of null #54

Closed MarbleDaemon closed 7 years ago

MarbleDaemon commented 7 years ago

I'm submitting a ... (check one with "x")

[ x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/HackedByChinese/ng2-idle/blob/master/CONTRIBUTING.md#getting-help

Current behavior

When Idle start: onIdleStart:

core.es5.js:1084 ERROR TypeError: Cannot read property 'getTime' of null at watchFn (idle.js:202) at ZoneDelegate.webpackJsonp.1271.ZoneDelegate.invokeTask (zone.js:424) at Object.onInvokeTask (core.es5.js:4140) at ZoneDelegate.webpackJsonp.1271.ZoneDelegate.invokeTask (zone.js:423) at Zone.webpackJsonp.1271.Zone.runTask (zone.js:191) at ZoneTask.invoke (zone.js:486) at timer (zone.js:1512)

Expected behavior

Subscription to onIdleStart should be triggered.

Minimal reproduction of the problem with instructions

This is the method used in AppComponent

constructor(private idle: Idle) {
   this.setupIdle();
}

 private setupIdle() {
    this.idle.setIdle(20);

    this.idle.onIdleStart.subscribe(() => {
        ....
    });

    this.resetIdle();
  }

private resetIdle() {
    this.idle.watch(true);
  }

What is the motivation / use case for changing the behavior?

Auto logout when user idle

Please tell us about your environment:

Windows 10, IntelliJ IDEA, NPM, Node.js

moribvndvs commented 7 years ago

Thanks, this is fixed in beta.12