fix(classes): cleanup resources, add cancellable timeouts, and fix bugs in several core utility classes

This commit is contained in:
2026-03-01 19:21:42 +00:00
parent 597e9e15c3
commit ddf4e698c9
11 changed files with 197 additions and 35 deletions

View File

@@ -62,8 +62,15 @@ export class ObjectMap<T> {
* remove key
* @param functionArg
*/
public removeMappedUnique(uniqueKey: string) {
const object = this.getMappedUnique(uniqueKey);
public removeMappedUnique(uniqueKey: string): T {
const object = this.fastMap.removeFromMap(uniqueKey);
if (object !== undefined) {
this.eventSubject.next({
operation: 'remove',
payload: object,
});
}
return object;
}
/**
@@ -220,8 +227,13 @@ export class ObjectMap<T> {
* wipe Objectmap
*/
public wipe() {
for (const keyArg of this.fastMap.getKeys()) {
this.fastMap.removeFromMap(keyArg);
const keys = this.fastMap.getKeys();
for (const keyArg of keys) {
const removedObject = this.fastMap.removeFromMap(keyArg);
this.eventSubject.next({
operation: 'remove',
payload: removedObject,
});
}
}
@@ -243,4 +255,12 @@ export class ObjectMap<T> {
public addAllFromOther(objectMapArg: ObjectMap<T>) {
this.fastMap.addAllFromOther(objectMapArg.fastMap);
}
/**
* destroys the ObjectMap, completing the eventSubject and clearing all entries
*/
public destroy() {
this.wipe();
this.eventSubject.complete();
}
}