mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-12 19:36:54 +01:00
13 lines
265 B
JavaScript
13 lines
265 B
JavaScript
let _cleanup = [];
|
|
|
|
export async function init($root) {
|
|
$root.cleanup = () => {
|
|
const fns = _cleanup.map((fn) => fn($root))
|
|
_cleanup = [];
|
|
return Promise.all(fns);
|
|
};
|
|
}
|
|
|
|
export async function onDestroy(fn) {
|
|
_cleanup.push(fn);
|
|
}
|