resource-scope
v0.0.1
Published
JavaScript resources auto run, collect and dispose
Downloads
2
Maintainers
Readme
ResourceScope
JavaScript resources auto run, collect and dispose
Features
Frame independent
Lightweight, zero runtime dependency
Typescript Support
install
$ npm install resource-scope
usage
import { resourceScope } from "resource-scope";
const scope = eventScope();
scope.run(() => {
// resize
window.addEventListener("resize", () => console.log("resize"));
// IntersectionObserver
const intersectionObserver = new IntersectionObserver(() =>
console.log("IntersectionObserver"),
);
document.querySelectorAll("*").forEach((item) => {
intersectionObserver.observe(item);
});
// setInterval
setInterval(() => {
console.log("setInterval");
}, 1000);
});
scope.dispose();
supported
addEventListener
intersectionObserver
setInterval
TODO...