title: How to get Firebase current user uid long after login?
body: <p>I'm new to Firebase and working in an angular project. I want to access the Firebase currentUser uid (on a component other than the login component). </p>
  
  <p>After some searching I found that this can be done using Firebase <code>auth().onAuthStateChanged()</code> method after logging in. But this will allow me to access uid only once after logging in and also only in the login component. But I want that uid in another component.</p>
  
  <p>I have to query my database using that uid. I could not find the best way to do it. One way I figured out was to save the uid and share it with the other component, but this doesn't seem a nice way to do it.</p>
  
  <p><img src="https://i.stack.imgur.com/tXxCJ.png" alt="My Firebase database looks like this"></p>
  
  <p>The hierarchy is</p>
  
  <pre><code>uid--&gt;random_id_1--&gt;{data}
     --&gt;random_id_2--&gt;{data}
  </code></pre>
  
  <p>So to access the data I need the uid of current user. I want it in another angular component.</p>