Today's npm package: reinterval

I am developer from India currently based in Berlin, Germany.
I am very interested in Design, though I don't design 😉 I take care of it while making my apps.
Photography, videography and having random conversation over beer are my activities of spare time. Timelapses and hyperlapses make me wonder all the time 😊
Today's npm package is reintereval
Some times in an application, you might have to do certain tasks repeatedly. Obvious solution is setInterval
Though as the project and related solution expands, it becomes bigger and harder to manage.
And, reintereval is going to help us in this direction.
It allows to create, stop and restart such interval tasks with just one instance and effectively increases the readability.
Let's see how to use it:
const reinterval = require('reinterval');
const poller = reinterval(() => {
console.log('Hello', new Date());
}, 3500);
setTimeout(() => {
console.log('cleared')
poller.clear()
}, 15000);
setTimeout(() => {
console.log('rescheduled')
poller.reschedule(1000)
}, 16000);
setTimeout(() => {
console.log('destroyed')
poller.destroy()
}, 19000)
See it in action here: https://runkit.com/pankaj/reintereval
Stay tuned for tomorrow's package of the Day.




