add remove method to entities service

This commit is contained in:
Dan Percic 2022-02-18 18:54:18 +02:00
parent a9cddbf19b
commit ab4568eb9d

View File

@ -96,6 +96,14 @@ export class EntitiesService<E extends IListable, I = E> extends GenericService<
}
}
remove(id: string) {
const entity = this.all.find(item => item.id === id);
if (entity) {
this._all$.next(this.all.filter(item => item.id !== id));
this._entityDeleted$.next(entity);
}
}
find(id: string): E | undefined {
return this.all.find(entity => entity.id === id);
}