Pankaj Patel
Pankaj Patel

Pankaj Patel

Today's npm package: reinterval

Today's npm package: reinterval

Pankaj Patel's photo
Pankaj Patel
ยทJun 18, 2021ยท

1 min read

Subscribe to my newsletter and never miss my upcoming articles

Play this article

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(() => {
}, 15000);

setTimeout(() => {
}, 16000);

setTimeout(() => {
}, 19000)

See it in action here:

Stay tuned for tomorrow's package of the Day.

Share this