I am working on an angular application for work that needs to implement permissions. The permissions are currently stored in the backend as a 1 or a 0, and the front end calls a service to return the user's permission and if the user does not have permission for a certain action, the button to perform that action is disabled. We thought about it for a while and decided that the best option would be to save the permission to session storage on start up and get it from there whenever it needs to be checked.
This works very well after the application starts, every page successfully reads the permission and disabled the appropriate buttons, however I am having an issue with the initial start up of the application. The permission must be received through an asynchronous method, so the application continues startup while the permission is being received. Since the default is no permission, the first page has a button disabled even after the permission is received because it was created before the asynchronous method was called. After a refresh it works as intended.
I have been trying to find a way to either detect when the change is made to session storage and update the initial component accordingly or have the application wait for the method to get permissions to finish before continuing startup. Any help would be appreciated.
-Thanks