mirror of
https://github.com/FJurmanovic/wallet-web.git
synced 2026-02-06 06:08:10 +00:00
implemented toasts
This commit is contained in:
20
src/core/utils/timer.ts
Normal file
20
src/core/utils/timer.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
const Timer = function (callback, delay, ...args) {
|
||||
var timerId,
|
||||
start,
|
||||
remaining = delay;
|
||||
|
||||
this.pause = function () {
|
||||
window.clearTimeout(timerId);
|
||||
remaining -= Date.now() - start;
|
||||
};
|
||||
|
||||
this.resume = function () {
|
||||
start = Date.now();
|
||||
window.clearTimeout(timerId);
|
||||
timerId = window.setTimeout(callback, remaining, ...args);
|
||||
};
|
||||
|
||||
this.resume();
|
||||
};
|
||||
|
||||
export default Timer;
|
||||
Reference in New Issue
Block a user