I am assigning the value of a property inside an observable:

).subscribe( userRole => {
  this.userRole = userRole; // userRole = true;

My property userRole now have the value true. The problem is that I need to use userRole property immediately with the value true into other methods but when other methods get executed, userRole value is still undefined. I am aware, this should be a problem of asynchronous but I would like to have the value true immediately to keep working with that value inside other methods.

I tried executing the rest of methods after the userRole assignation inside the subscribe and that works but for code organization reasons I need to place the rest of methods outside the subscription.

Maybe other solution is to force the code execution to wait until first subscription finishes

Anonymous Asked question May 14, 2021