title: Dispatch action on the callback of socket.on()
body: <p>So basically I got this socket, that is working correctly sending me 'new order' message.</p>
  
  <p>I'm using redux, and i want to dispatch an action, than a reducer would get it and my store would be updated. but this code doesn't do anything!</p>
  
  <pre><code>socket.on('new order', (order) =&gt; {    
      return (dispatch) =&gt; {
        dispatch(socketNewOrder(order));
      }
  });
  </code></pre>
  
  <p>And here is my action, which is located at the same file:</p>
  
  <pre><code>export const socketNewOrder = (order) =&gt; {
    return {
      type: 'SOCKET_NEW_ORDER',
      payload: order
    }
  }
  </code></pre>
  
  <p>I also tried to call my action like this:</p>
  
  <pre><code>socket.on('new order', (order) =&gt; {    
      socketNewOrder(order));        
  });
  </code></pre>
  
  <p>It called the action indeed, but the action wasn't 'heard' by my reducer! :(</p>
  
  <p>I heard something about using middlewares, but i just can't figure out how to do it.</p>
  
  <p>Could anyone explain me how to use middlewares for dispatching actions as i receive socket messages, and why my code doesn't work? Thanks and sorry for newbie questio</p>