idle-timer-manager
v0.0.5
Published
Idle timer manager for web application
Downloads
1,799
Readme
Idle Timer Manager
React Usage
import React, { useEffect, useState } from "react";
import { IdleTimeoutManager } from "idle-timer-manager";
const Child = () => {
const [text, setText] = useState("Child")
useEffect(() => {
const manager = new IdleTimeoutManager({
timeout: 10, //expired after 10 secs
onExpired: (time) => {
setText(`Expired at ${time}`);
}
});
return () => {
manager.clear();
}
}, []);
return <div>{text}</div>
}
export default Child;
Angular Usage
import { Component } from "@angular/core";
import { IdleTimeoutManager } from "idle-timer-manager";
@Component({
selector: "app-root",
templateUrl: "./app.component.html"
})
export class AppComponent {
ngOnInit() {
this.timer = new IdleTimeoutManager({
timeout: 10, //expired after 10 secs
onExpired: () => {
console.log("Expired");
}
});
}
ngOnDestroy() {
this.timer.clear();
}
}