but i need some solution with app component so i don’t have to do major changes.
i have a scenario where user can update his profile info .for example user edits user name now the API call updates the data and also i save the updated data to local storage. this local storage contains the updated name too, which i want to display on side menu and this menu is in app component.
any help how can i do that?
i tried to call the local storage in app component but it seems like that it only loads once.
I said create your own EventsService. The one you mentioned there is not even available any more.
And exactly what @rapropos said is what i mean. If you don’t know how to create that and how to use Subjects/Obseevables i would recommend to investigate a bit more time into understanding Angular and rxjs.
Comments are a mixed blessing. What’s much better is self-documenting code, which includes naming conventions. When I see a bare user, I instantly assume “that’s a lexically-scoped variable”. Having that name potentially collide with a type of the name user is confusing. So types should always start with a capital letter (PascalCase).
Secondly, since you already bothered to define a User type, that’s great. Use it. profile: User, not profile: any. any totally nerfs much of the value in using TypeScript in the first place. You virtually never need it in your own code - it’s generally most needed when writing libraries.