diff --git a/ts/lik.objectmap.ts b/ts/lik.objectmap.ts index 4c56a15..ee7db7a 100644 --- a/ts/lik.objectmap.ts +++ b/ts/lik.objectmap.ts @@ -14,6 +14,9 @@ export interface IObjectmapFindFunction { export class Objectmap { private objectArray: T[] = []; + // events + public eventSubject = new plugins.smartrx.rxjs.Subject(); + /** * returns a new instance */ @@ -33,6 +36,7 @@ export class Objectmap { } else { // the object is not yet in the objectmap this.objectArray.push(objectArg); + this.eventSubject.next('add'); return true; } } @@ -89,7 +93,9 @@ export class Objectmap { * gets an object in the Observablemap and removes it, so it can't be retrieved again */ public getOneAndRemove(): T { - return this.objectArray.shift(); + const removedItem = this.objectArray.shift(); + this.eventSubject.next('remove'); + return removedItem; } /** @@ -125,6 +131,7 @@ export class Objectmap { } } this.objectArray = replacementArray; + this.eventSubject.next('remove'); } /** @@ -132,5 +139,6 @@ export class Objectmap { */ public wipe() { this.objectArray = []; + this.eventSubject.next('wiped'); } }