title: Redux thunk: return promise from dispatched action
body: <p>Is it possible to return promise/signal from action creator, resolved when Redux thunk has successfully dispatched certain action?</p>
  
  <p>Consider this action creator:</p>
  
  <pre><code>function doPost(data) {
      return (dispatch) =&gt; {
          dispatch({type: POST_LOADING});
          Source.doPost() // async http operation
              .then(response =&gt; {
                  dispatch({type: POST_SUCCESS, payload: response})
              })
              .catch(errorMessage =&gt; {
                  dispatch({type: POST_ERROR, payload: errorMessage})
              });
      }
  }
  </code></pre>
  
  <p>I want to call some function asynchronously <em>in the component</em> after calling <em>doPost</em> action creator when Redux has either dispatched POST_SUCCESS or POST_ERROR actions. One solution would be to pass the callback to action creator itself, but that would make code messy and hard to grasp and maintain. I could also poll the Redux state in while loop, but that would be inefficient.</p>
  
  <p>Ideally, solution would be a promise, which should resolve/reject when certain actions (in this case POST_SUCCESS or POST_ERROR) gets dispatched.</p>
  
  <pre><code>handlerFunction {
    doPost(data)
    closeWindow()
  }
  </code></pre>
  
  <p>The above example should be refactored, so closeWindow() gets called only when doPost() is successful.</p>