{"size": 532, "ext": "js", "max_stars_repo_path": "src/game/controls/controlsActions.js", "max_stars_repo_name": "davelucas/react-bowling-kata", "max_stars_repo_stars_event_min_datetime": "2018-02-14T00:01:10.000Z", "max_stars_repo_stars_event_max_datetime": "2018-02-14T00:01:10.000Z", "max_issues_repo_path": "src/game/controls/controlsActions.js", "max_issues_repo_name": "davelucas/react-bowling-kata", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/game/controls/controlsActions.js", "max_forks_repo_name": "davelucas/react-bowling-kata", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 20.4615384615, "max_line_length": 60, "alphanum_fraction": 0.6879699248}
import simulatedBowl from './bowlingSimulator';
import { handleBowlFinished } from '../gameActions';

export const START_BOWLING = 'START_BOWLING';
export const NEW_GAME = 'NEW_GAME';

function startBowling() {
  return {
    type: START_BOWLING,
  };
}

export function newGame() {
  return {
    type: NEW_GAME,
  };
}

export function bowlABall() {
  return (dispatch, getState) => {
    dispatch(startBowling());
    return simulatedBowl(getState().lane.pins)
      .then(result => dispatch(handleBowlFinished(result)));
  };
}
