{"size": 947, "ext": "js", "max_stars_repo_path": "src/AC/articles.js", "max_stars_repo_name": "AZhuravski/Store-Prototype", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/AC/articles.js", "max_issues_repo_name": "AZhuravski/Store-Prototype", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/AC/articles.js", "max_forks_repo_name": "AZhuravski/Store-Prototype", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 36.4230769231, "max_line_length": 123, "alphanum_fraction": 0.7117212249}
import AppDispatcher from '../dispatcher'
import { DELETE_ARTICLE, LOAD_ALL_ARTICLES, LOAD_ARTICLE_BY_ID, LOAD_COMMENTS_FOR_ARTICLE } from '../constants'
import { loadAll, loadById } from './api/articles'
import { loadForArticle } from './api/comments'
import { asyncAC, promisification } from './utils'
import history from '../history'

export function deleteArticle(id) {
    AppDispatcher.dispatch({
        type: DELETE_ARTICLE,
        data: { id }
    })
}

export const loadAllArticles = asyncAC(loadAll, LOAD_ALL_ARTICLES)
//export const loadArticleById = asyncAC(loadById, LOAD_ARTICLE_BY_ID, (dfd) => dfd.fail(() => history.push('/articles/')))

export const loadArticleById = (...args) => {
	Promise.all([
		promisification( asyncAC(loadById, LOAD_ARTICLE_BY_ID, (dfd) => dfd.fail(() => history.push('/articles/'))), ...args),
		promisification( asyncAC(loadForArticle, LOAD_COMMENTS_FOR_ARTICLE), ...args)
	]).then(results => {});
}


