In my method I need to return "this.profile". But I can't use this.profile outside my profileObservable
profileObservable: Observable<ProfileModel>;
profile: ProfileModel;
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<ProfileModel> {
this.store$.dispatch(new ProfileFeatureStoreActions.GetProfile());
this.profileObservable = this.store$.pipe(
select(
ProfileFeatureStoreSelectors.selectProfile
),
filter(profile => !!profile)
);
this.profileObservable.subscribe(profile => {
this.profile = profile;
console.log(this.profile) // here is defined
});
return this.profile; //it's undefined
}
If you have the solution thank you so much