Is there a way to modify this forkJoin function so that it returns an observable array instead of a subscription?
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$
]).subscribe(([habits, statuses]) => {
this.joined = habits.map(habit => ({
...statuses.find(t => t.habitId === habit.habitId),
...habits
}));
});
return this.joined$;
}
Currently, my variables are declared as follows:
export class HabitDataSource extends DataSource<any> {
userId: Pick<User, 'id'>;
habits$: Observable<Habit[]>;
status$: Observable<Status[]>;
joined$: Subscription;
joined: any[];
However, the connect() method requires an Observable-Array format.