I am trying to implement ng-idle from this answer : Set the logout time if user is inactive?
My Source code :
- New project created. ionic start NgIdleApp blank --type=ionic-angular
- Used the command : npm install --save @ng-idle/core
- Changed my App.component.ts to this:
import { Component } from ‘@angular/core’;
import { Platform } from ‘ionic-angular’;
import { StatusBar } from ‘@ionic-native/status-bar’;
import { SplashScreen } from ‘@ionic-native/splash-screen’;
import { HomePage } from ‘…/pages/home/home’;
import { Idle, DEFAULT_INTERRUPTSOURCES } from ‘@ng-idle/core’;
@Component({
templateUrl: ‘app.html’
})
export class MyApp {
rootPage:any = HomePage;
constructor(
private idle: Idle,
platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
platform.ready().then(() => {
this.idleManagement();
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar.styleDefault();
splashScreen.hide();
});
}
idleManagement() {
// sets an idle timeout of 5 seconds, for testing purposes.
this.idle.setIdle(10);
// sets a timeout period of 5 seconds. after 10 seconds of inactivity, the user will be considered timed out.
this.idle.setTimeout(10);
// sets the default interrupts, in this case, things like clicks, scrolls, touches to the document
this.idle.setInterrupts(DEFAULT_INTERRUPTSOURCES);
this.idle.onIdleEnd.subscribe(() => { console.log("No longer idle."); });
this.idle.onTimeout.subscribe(() => {
console.log("Timed out!");
// this.timedOut = true;
});
this.idle.onIdleStart.subscribe(() => { console.log("You've gone idle!"); });
this.idle.onTimeoutWarning.subscribe((countdown) => {
console.log("You will time out in " + countdown + " seconds!");
});
}
}
- used command : ionic serve
- Image output
Error : Object(WEBPACK_IMPORTED_MODULE_0_rxjs[“fromEvent”]) is not a function. (In ‘Object(WEBPACK_IMPORTED_MODULE_0_rxjs[“fromEvent”])(target, eventName, opts)’, ‘Object(WEBPACK_IMPORTED_MODULE_0_rxjs[“fromEvent”])’ is an instance of Object)
Can anyone help me out with this?