timer.js
This timer is very simple and framework independent.
Install
npm install @shhhplus/timer.js --save
How to use
sync
import createTimer from '@shhhplus/timer.js';
const timer = createTimer({
interval: 1000,
onElapsed: () => {
console.log('onElapsed ...');
},
});
timer.start();
timer.stop();
async
import createTimer from '@shhhplus/timer.js';
const timer = createTimer({
interval: 5000,
onElapsed: () => {
console.log('onElapsed ...');
return new Promise((resolve) => {
setTimeout(resolve, 500);
});
},
});
timer.start();
timer.stop();