In my Angular 8 application, I have a service structured like this:
export class ProfileUserService {
user$ = this.authService.loginStatus().pipe(take(1));
constructor(private profileService: ProfileService, private authService: AuthService) {}
getProfile(): Observable<ProfileApi> {
return this.user$.pipe(mergeMap(({ profile }) => this.profileService.get(profile.participant)));
}
}
Within a component called SettingsAccountComponent, I utilize this service by calling the method as shown below:
export class SettingsAccountComponent extends FormCanDeactivate implements OnInit, OnDestroy {
constructor(
private profileUserService: ProfileUserService){}
ngOnInit() {
this.innerWidth = window.innerWidth;
this.profileSubscription = this.profileUserService.getProfile().subscribe((profile: ProfileApi) => {
this.profile = profile;
this.deletePicture = false;
this.buildForm();
});
}
}
However, I would like to directly call the ProfileService within the SettingsAccountComponent component like this:
private profileService: ProfileService
The issue arises with the following line of code:
user$ = this.authService.loginStatus().pipe(take(1));
As I require this for retrieving the participantId. Therefore, my question is: How can I integrate the ProfileService, specifically this section:
this.profileSubscription = this.profileService.get().subscribe((profile: ProfileApi) => {
this.profile = profile;
this.deletePicture = false;
this.buildForm();
});
With the following code snippet:
user$ = this.authService.loginStatus().pipe(take(1));
since the get() method currently expects a ParticipantId?
What changes do I need to make to address this issue?
Thank you