title: Redux + React + FireBase: how to use a state when updating
body: <h1>Hello guys and girls :)</h1>
  
  <p>I'm starting with Firebase &amp;&amp; Redux and I'm having some issues with the callback <code>on</code>-function of <code>firebase.database().ref()</code> within the formular</p>
  
  <pre><code>function getAll() {
  
      const uid = JSON.parse(localStorage.getItem('user'))
          .uid;
  
  
      const dbRef = firebase.database()
          .ref().child('events');
  
      const userRef = dbRef.child(uid);
  
      let answer = [];
  
      userRef.on('value', snap =&gt; {
          let rx = snap.val();
          for (let item in snap.val()) {
              answer.push(rx[ item ]);
          }
      });
  
      return Promise.resolve({
          events: answer
      });
  }
  </code></pre>
  
  <h2>What was I doing ?</h2>
  
  <p>I've created before some actions (triggers) to call this services and this method must fire before the result be saved with reducers in the <code>store</code>.</p>
  
  <p>This is what is expected. <em>But</em>,...</p>
  
  <h2>What is my actual reality ?</h2>
  
  <ul>
  <li>The method fires in time, good new :-) <em>but</em>,</li>
  <li>The <code>callback</code> (as it is) fires some seconds after (<code>1</code> or <code>1.5s</code>) while the <code>redux</code> itself, very fast unit, fires and make the react render at the same time. In short, the components are rendered lots before the firebase callback gives back a value. </li>
  </ul>
  
  <p>At the final then I need to render, reload the page, change to another route of the application so that the saved changes can be applied to render.</p>
  
  <p>Since I'm beginning with <em>redux</em> and <em>firebase</em>, I'm not <code>100%</code> (but only <code>70%</code>) sure of this deductions, but they are the betters I could've found in this situation.</p>
  
  <h2>What's then the situation ?</h2>
  
  <p>I'm starving for any help now and thank you for any help you could provide me :)</p>