mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2024-04-21 12:32:08 +00:00
14 lines
266 B
JavaScript
14 lines
266 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);
|
|
}
|