function populateAndDispatch(firebase, dispatch, config) {
  const { data, populates, snapshot, path, storeAs } = config
  // TODO: Allow setting of unpopulated data before starting population through config
  return promisesForPopulate(firebase, snapshot.key, data, populates)
    .then((results) => {
      // dispatch child sets first so isLoaded is only set to true for
      // populatedDataToJS after all data is in redux (Issue #121)
      // TODO: Allow config to toggle Combining into one SET action
      // TODO: Set ordered for populate queries
      forEach(results, (result, path) => {
        dispatch({
          type: actionTypes.MERGE,
          path,
          data: result
        })
      })
      dispatch({
        type: actionTypes.SET,
        path: storeAs || path,
        data,
        ordered: orderedFromSnapshot(snapshot)
      })
      return results
    })
    .catch((err) => {
      dispatch({
        type: actionTypes.ERROR,
        payload: err
      })
      return Promise.reject(err)
    })
}
Get data associated with populate settings, and dispatch

@param {object} firebase - Internal firebase object
@param {Function} dispatch - Redux's dispatch function
@param {object} config - Config object
@param {any} config.data - Original query data result
@param {Array} config.populates - List of populate settings
@param {string} config.path - Base query path
@param {string} config.storeAs - Location within redux in which to
query results will be stored (path is used as default if not provided).
@returns {Promise} Promise that resolves after data for populates has been
loaded and associated actions have been dispatched
@private