/** * https://github.com/Noah2610/i3-color-theme-editor/blob/master/src/util/unsubs.ts */ export interface Unsubs { add(fn: () => void): void; unsubAll(): void; fns: (() => void)[]; } export function createUnsubs(): Unsubs { const fns: Unsubs["fns"] = []; return { add(fn) { fns.push(fn); }, unsubAll() { fns.forEach((unsub) => unsub()); }, fns, }; }