I am using forkJoin to join two observable arrays together:
connect(): Observable<any[]> {
this.userId = this.authService.userId;
this.habits$ = this.habitService.fetchAllById(this.userId);
this.status$ = this.statusService.fetchAll();
this.joined$ = forkJoin([this.habits$, this.status$]).pipe(
map(([habits, statuses]) =>
habits.map(habit => ({
...habit,
status: statuses.find(s => s.habitId === habit.habitId)
})))
);
console.log(this.joined$);
return this.joined$;
In my mapping function I am mapping the habitId from my each habit-Observable to the habitId from my status-Observable.
Which is working fine. The problem is, I have multiple objects in my status$-Oberservable which I want to map to one habitId of one habit$-Oberservable. How to do this?
