UNPKG

rc-js-util

Version:

A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.

27 lines 852 B
import { DirtyCheckedUniqueCollection } from "../collection/dirty-checked-unique-collection.js"; /** * @public * Strong reference implementation of {@link ICleanupRegistry}. */ export class CleanupRegistry { constructor() { this.cleanupCallbacks = new DirtyCheckedUniqueCollection(); } executeCleanups() { const cleanupCallbacks = this.cleanupCallbacks.getArray(); for (let i = 0, iEnd = cleanupCallbacks.length; i < iEnd; i++) { cleanupCallbacks[i](); } this.cleanupCallbacks.clear(); } registerCleanup(listener) { this.cleanupCallbacks.add(listener); } unregisterCleanup(listener) { this.cleanupCallbacks.delete(listener); } listCleanups() { return this.cleanupCallbacks.getArray(); } } //# sourceMappingURL=cleanup-registry.js.map