src/data.js
function fetchProps(props, match) {
  var newProps = {};

  var deferreds = {};
  var promises = {};
  var tasks = {};

  var name;

  for (name in props) {
    var m = isPromisePropRe.exec(name);
    if (m) {
      var promiseName = m[1];
      var deferred = Promise.defer();
      tasks[promiseName] = makeTask(props[name], deferred);
      deferreds[promiseName] = deferred.promise;
    } else {
      newProps[name] = props[name];
    }
  }

  // not *Promise props, shortcircuit!
  if (Object.keys(deferreds).length === 0) {
    return Promise.resolve(props);
  }

  var isFulfilled = true;

  for (name in tasks) {
    var promise = tasks[name](newProps, deferreds, match);
    isFulfilled = isFulfilled && promise.isFulfilled();
    promises[name] = promise.isFulfilled() ? promise.value() : promise;
  }

  // every promise is resolved (probably from some DB cache?), shortcircuit!
  if (isFulfilled) {
    return Promise.resolve(merge(newProps, promises));
  }

  return Promise.props(promises)
    .then((props) => merge(newProps, props))
    .finally(() => {
      for (var name in deferreds) {
        deferreds[name].catch(emptyFunction);
      }
    });
}
function fetchProps(props, match) {
  var newProps = {};

  var deferreds = {};
  var promises = {};
  var tasks = {};

  var name;

  for (name in props) {
    var m = isPromisePropRe.exec(name);
    if (m) {
      var promiseName = m[1];
      var deferred = Promise.defer();
      tasks[promiseName] = makeTask(props[name], deferred);
      deferreds[promiseName] = deferred.promise;
    } else {
      newProps[name] = props[name];
    }
  }

  // not *Promise props, shortcircuit!
  if (Object.keys(deferreds).length === 0) {
    return Promise.resolve(props);
  }

  var isFulfilled = true;

  for (name in tasks) {
    var promise = tasks[name](newProps, deferreds, match);
    isFulfilled = isFulfilled && promise.isFulfilled();
    promises[name] = promise.isFulfilled() ? promise.value() : promise;
  }

  // every promise is resolved (probably from some DB cache?), shortcircuit!
  if (isFulfilled) {
    return Promise.resolve(merge(newProps, promises));
  }

  return Promise.props(promises)
    .then((props) => merge(newProps, props))
    .finally(() => {
      for (var name in deferreds) {
        deferreds[name].catch(emptyFunction);
      }
    });
}
function fetchProps ( props , match ) { var newProps = { } ; var deferreds = { } ; var promises = { } ; var tasks = { } ; var name ; for ( name in props ) { var m = isPromisePropRe . exec ( name ) ; if ( m ) { var promiseName = m [ 1 ] ; var deferred = Promise . defer ( ) ; tasks [ promiseName ] = makeTask ( props [ name ] , deferred ) ; deferreds [ promiseName ] = deferred . promise ; } else { newProps [ name ] = props [ name ] ; } } // not *Promise props, shortcircuit! if ( Object . keys ( deferreds ) . length === 0 ) { return Promise . resolve ( props ) ; } var isFulfilled = true ; for ( name in tasks ) { var promise = tasks [ name ] ( newProps , deferreds , match ) ; isFulfilled = isFulfilled && promise . isFulfilled ( ) ; promises [ name ] = promise . isFulfilled ( ) ? promise . value ( ) : promise ; } // every promise is resolved (probably from some DB cache?), shortcircuit! if ( isFulfilled ) { return Promise . resolve ( merge ( newProps , promises ) ) ; } return Promise . props ( promises ) . then ( ( props ) => merge ( newProps , props ) ) . finally ( ( ) => { for ( var name in deferreds ) { deferreds [ name ] . catch ( emptyFunction ) ; } } ) ; }
Fetch all promises defined in props

@param {Object} props
@returns {Promise<Object>}
Fetch all promises defined in props