Skip to content

Add observable to indicate if User Profile was loaded #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jeroenheijmans opened this issue Mar 10, 2022 · 2 comments
Open

Add observable to indicate if User Profile was loaded #107

jeroenheijmans opened this issue Mar 10, 2022 · 2 comments
Labels
enhancement Request for improvement

Comments

@jeroenheijmans
Copy link
Owner

In the main service of this sample we load the User Profile like this:

this.oauthService.events
.pipe(filter(e => ['token_received'].includes(e.type)))
.subscribe(e => this.oauthService.loadUserProfile());

I suspect some people will want to "wait" for the profile to be loaded before doing stuff. So it might make sense to add isUserProfileLoaded$ observable similar to isAuthenticated$ and isDoneLoading$.

@jeroenheijmans jeroenheijmans added the enhancement Request for improvement label Mar 10, 2022
@rms2219
Copy link

rms2219 commented Dec 27, 2023

However this is solved, this would be very useful for us. We have several components that rely on information coming from the response to loadUserProfile. As it stands, we're dealing with a race condition where a component is loaded before the user profile request completes. We can probably add something akin to your APP_INITIALIZER process. However (and this is untested and could be completely incorrect), I believe that if a user were to logout and log back in (not refreshing/reinitializing the app), then the user profile data would need to be re-requested and I'd be back in the same situation.

Anyway, I'm interested in a solution here and happy to provide more details of our situation to help develop one.

@jeroenheijmans
Copy link
Owner Author

Thanks for the feedback! That sounds like a typical use case indeed.

Don't think too much of the proposed feature by the way, it would probably be a very straightforward boolean observable similar to isAuthenticated$.

I'm not sure if I'll get to introducing this all too soon though, as my open source focus is currently mostly elsewhere.

If anyone ends up doing an implementation feel free to let us know what approach you took!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Request for improvement
Projects
None yet
Development

No branches or pull requests

2 participants