Skip to content

A variant of setInterval that returns a cleanup function.

License

Notifications You must be signed in to change notification settings

cfware/cleanable-interval

Repository files navigation

@cfware/cleanable-interval NPM Version

A variant of setInterval that returns a cleanup function.

Usage

import cleanableInterval from '@cfware/cleanable-interval';

let iter = 0;
const cleanupFn = cleanableInterval(() => {
	iter++;
	console.log(`Iteration ${iter} of 2`);
	if (iter > 1) {
		cleanupFn();
	}
}, 100);

About

A variant of setInterval that returns a cleanup function.

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published