import {ERROR, INIT, LOADING, OK} from '../../redux/constants';

export function fetchData(fetchFunction) {
  fetchFunction();
}

export function mergeStatuses(statuses) {
  let isOK = true;
  for (let i = 0; i < statuses.length; i++) {
    if (statuses[i] === INIT) return INIT;
    if (statuses[i] === ERROR) return ERROR;
    isOK = isOK && (statuses[i] === OK);
  }
  return isOK ? OK : LOADING;
}
