I have a fuction inside my service which returns an observable array of entity ids and I have another function, which takes an entity id, with which I can get detailed information of an entity as an observable.
Now I want to requests all entity ids with the first function an then pipe those ids one by one into the second function to get one big observable with all my detailed entity informations.
Just to talk about the same functions:
this.api.getEntities() -> gets all entity ids
this.api.getEntity(id) -> gets information of a single entity
This is what i tried so far but its just working with when there is only one entity, with two or more entities id = 1, 2.
this.entities$ = this.api.getEntities().pipe(switchMap(id => this.api.getEntity(id)));
My working solution now is:
this.entities$ = this.api.getEntities().pipe(switchMap(ids => forkJoin(ids.map(id => this.api.getEntity(id)))));