title: Angular - How to deal with Observable of <User | null>
body: <p>I'm building an authentication service and I want to provide the current user to components in the Angular app.</p>
  <p>I'm using a subject / observable of type <code>&lt;User | null&gt;</code> because I want to show when the user is not available. E.g. he is not logged in. However, this causes some problems so I can no longer easily access it in components. (Because of <code>null</code>)</p>
  <p>So I was wondering how to properly deal with it. I know this problem seems pretty simple and I hope you can provide some tips or best practice as this won't be the last.</p>
  <p>AuthService:</p>
  <pre class="lang-js prettyprint-override"><code>// initially null
  private readonly _currentUser = new BehaviorSubject&lt;ApiModel.User | null&gt;(null);
  public readonly currentUser$ = this._currentUser.asObservable();
  </code></pre>
  <p>Component:</p>
  <p><code>{{user.email | async }}</code> -&gt;</p>
  <p><code>Property 'email' does not exist on type 'Observable&lt;User | null&gt;</code></p>
  <p><code>User</code> is just an interface. In the component I inject the service and then provide the observable as <code>user</code>.</p>