title: Recalculating after multiple Flux state update
body: <p>I have a React application using Flux written in Typescript.  On the page are two bootstrap drop down buttons which contain possible values for the user to select in order to influence a query result set.</p>
  
  <p>Using the normal Flux Actions and Stores, I invoke a couple of api calls to retrieve the values in json of the drop-down button lists which are bound to state.</p>
  
  <p>I am attempting to do an initial trigger of the calculation function which needs values from both the drop-downs once the calls have completed but as the state setting is asynchronous I don't know when to trigger it?</p>
  
  <p>I have tried from the state setting functions on my component but I am always told I cannot dispatch while dispatching (i.e. call my calc function via the action/store method).</p>
  
  <p>How do I wait for both calls to complete before calling the function?</p>
  
  <pre><code>componentWillMount() {
      AvailabilityTimePresetsStore.addChangeListener(this._onChange_availabilityTimePresetsStore);
      AvailabilityTimePresetActions.getTimePresets();
  }
  
  _onChange_availabilityTimePresetsStore = () =&gt; {
          let timePresets = this._getStateFromAvailabilityTimePresetsStore().presets;
          // set initial value
          let currentPreset = this.state.selectedTimePreset;
          this.setState({ timePresetOptions: timePresets, selectedTimePreset: currentPreset == null ? timePresets[0] : currentPreset });
      }
  
  _getStateFromAvailabilityTimePresetsStore() {
      // retrieve the state from the store
      return AvailabilityTimePresetsStore.getState();
  }
  </code></pre>
  
  <p>The above is called when emitChange is fired from my TimePresetsStore.  I check to see if there was no previously selected preset and set the selectedTimePreset to the first one if not (it's an initial load).  At this point I want to fire my recalc() function to get the results from a query.  But if i call it here or as the callback ater setState I get the dispatcher error.  I also cannot tell here if the other drop-down has been populated and set in the same way and I need both to pass the selected values to the query.</p>