fix(classes): cleanup resources, add cancellable timeouts, and fix bugs in several core utility classes
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user