This commit is contained in:
Timo Bejan 2021-12-14 23:17:36 +02:00
parent 6bd54f11ab
commit caf4838be6

View File

@ -21,7 +21,7 @@ export class EntitiesService<E extends IListable, I = E> extends GenericService<
readonly noData$: Observable<boolean>;
readonly all$: Observable<E[]>;
readonly allLength$: Observable<number>;
protected readonly entityChanged$ = new Subject<E>();
protected readonly _entityChanged$ = new Subject<E>();
private readonly _all$ = new BehaviorSubject<E[]>([]);
constructor(
@ -61,7 +61,7 @@ export class EntitiesService<E extends IListable, I = E> extends GenericService<
}
getEntityChanged$(entityId: string): Observable<E | undefined> {
return this.entityChanged$.pipe(
return this._entityChanged$.pipe(
filter(entity => entity.id === entityId),
startWith(this.find(entityId)),
shareLast(),
@ -88,7 +88,7 @@ export class EntitiesService<E extends IListable, I = E> extends GenericService<
// Emit observables only after entities have been updated
for (const entity of changedEntities) {
this.entityChanged$.next(entity);
this._entityChanged$.next(entity);
}
}
@ -103,6 +103,6 @@ export class EntitiesService<E extends IListable, I = E> extends GenericService<
replace(entity: E): void {
const all = this.all.filter(item => item.id !== entity.id);
this.setEntities([...all, entity]);
this.entityChanged$.next(entity);
this._entityChanged$.next(entity);
}
}