feat: extract mapping to util function
This commit is contained in:
parent
7e7324156e
commit
6c47d98666
@ -11,13 +11,15 @@ export interface Disease {
|
||||
|
||||
type DiseaseResponse = Record<string, Disease[]>;
|
||||
|
||||
const flattenResult = (rawItems: DiseaseResponse): Disease[] => Object.values(rawItems).flat();
|
||||
|
||||
@Service()
|
||||
export class DiseaseService {
|
||||
private url = environment.resourceUrl;
|
||||
private readonly resource = httpResource<DiseaseResponse>(() => this.url);
|
||||
|
||||
readonly diseases = computed(() =>
|
||||
this.resource.hasValue() ? Object.values(this.resource.value()).flat() : [],
|
||||
this.resource.hasValue() ? flattenResult(this.resource.value()) : [],
|
||||
);
|
||||
|
||||
readonly isLoading = this.resource.isLoading;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user