mirror of
https://github.com/pockethost/pockethost.git
synced 2025-07-05 20:32:29 +00:00
16 lines
474 B
TypeScript
16 lines
474 B
TypeScript
import { createCleanupManager } from '$shared'
|
|
import { onDestroy } from 'svelte'
|
|
|
|
// TODO: Document this more
|
|
// This is used to queue up functions and then destroy them once completed
|
|
// Currently being used on the Logging.svelte file to better handle the Real time subscription from Pocketbase.
|
|
export const mkCleanup = () => {
|
|
const cm = createCleanupManager()
|
|
|
|
onDestroy(() => cm.shutdown().catch(console.error))
|
|
|
|
return (cb: () => any) => {
|
|
cm.add(cb)
|
|
}
|
|
}
|