Within the ngOnInit() method, I am implementing the following:
ngOnInit() {
const exerciseObs = this.wodService.getAllExercises().pipe(take(1), map(data => {
return {exercises: data};
}));
const userObs = this.accountService.getAccountInformationObservable().pipe(take(1), map(data => {
return {user: data};
}));
forkJoin([exerciseObs, userObs]).subscribe(data => {
this.exercises = data[0].exercises as unknown as Exercise[];
this.user = data[1].user as unknown as CWUser;
});
}
I am combining the results of two observables and then assigning the retrieved data to two different component properties. However, the conversion to 'unknown' followed by explicit typing seems awkward, but I have not been able to find another way to merge them without utilizing a switchMap function and performing the data merging within it. Despite feeling slightly off due to the returned array format and casting peculiarities, I believe that this approach offers a cleaner and more concise solution.
What aspect or detail am I possibly overlooking in this scenario?