get entity changed

This commit is contained in:
Dan Percic 2021-11-12 01:34:37 +02:00
parent 574a7316c3
commit 8beb712c54

View File

@ -1,9 +1,9 @@
import { Inject, Injectable, InjectionToken, Injector, Optional } from '@angular/core';
import { BehaviorSubject, Observable, Subject } from 'rxjs';
import { map, tap } from 'rxjs/operators';
import { filter, map, startWith, tap } from 'rxjs/operators';
import { IListable } from '../models';
import { GenericService, QueryParam } from '../../services';
import { getLength, List, mapEach, shareDistinctLast } from '../../utils';
import { getLength, List, mapEach, shareDistinctLast, shareLast } from '../../utils';
/**
* This should be removed when refactoring is done
@ -59,6 +59,14 @@ export class EntitiesService<E extends IListable, I = E> extends GenericService<
}
}
getEntityChanged$(entityId: string): Observable<E | undefined> {
return this.entityChanged$.pipe(
filter(entity => entity.id === entityId),
startWith(this.find(entityId)),
shareLast(),
);
}
setEntities(newEntities: E[]): void {
this._all$.next(newEntities);
}