title: Angular 8: Wait for subscribe response
body: <p>I have some issue in my auth guard  when I request for some data from the server 
  and my decide for routing is dependent on the response from server
  how can I wait for the server response for the next step?</p>
  
  <p>this is my code:</p>
  
  <pre><code>canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
      if (!this._sessionService.user) {
          this._router.navigate(['login']);
          return false;
      }
  
      this._userServiceProxy.get(this._sessionService.userId).subscribe((user: UserDto) =&gt; {
          if (user["result"].shouldChangePassword) {
              this._router.navigate([this.routeToChangePassword()]);
          }
          if ((!route.data || !route.data["permission"])) {
              return true;
          }
  
          if ((this._permissionChecker.isGranted(route.data["permission"]))) {
              return true;
          }
          this._router.navigate([this.selectBestRoute()]);
          return false;
      })
  
  }
  </code></pre>