{"size": 1201, "ext": "js", "max_stars_repo_path": "src/store/sagas/post.js", "max_stars_repo_name": "tranhoangduong1994/react-native-boilerplate", "max_stars_repo_stars_event_min_datetime": "2019-02-28T10:20:22.000Z", "max_stars_repo_stars_event_max_datetime": "2019-08-09T06:32:27.000Z", "max_issues_repo_path": "src/store/sagas/post.js", "max_issues_repo_name": "tranhoangduong1994/react-native-boilerplate", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/store/sagas/post.js", "max_forks_repo_name": "tranhoangduong1994/react-native-boilerplate", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 10, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.0208333333, "max_line_length": 65, "alphanum_fraction": 0.7568692756}
import { all, takeLatest } from 'redux-saga/effects';
import {
  ACTION_GET_POSTS,
  ACTION_ADD_POST,
  ACTION_UPDATE_POST,
  ACTION_DELETE_POST,
  ACTION_GET_POST_DETAILS
} from '../constants';
import PostAPIs from '../APIs/post';
import { createRequestSaga } from '../../utils/RequestSagaUtils';

const requestGetPosts = createRequestSaga({
  request: PostAPIs.getPosts,
  key: ACTION_GET_POSTS
});

const requestGetPostDetails = createRequestSaga({
  request: PostAPIs.getPostDetails,
  key: ACTION_GET_POST_DETAILS
});

const requestAddPost = createRequestSaga({
  request: PostAPIs.addPost,
  key: ACTION_ADD_POST
});

const requestUpdatePost = createRequestSaga({
  request: PostAPIs.updatePost,
  key: ACTION_UPDATE_POST
});

const requestDeletePost = createRequestSaga({
  request: PostAPIs.deletePost,
  key: ACTION_DELETE_POST
});

export default [
  function* postWatcher() {
    yield all([
      takeLatest(ACTION_GET_POSTS, requestGetPosts),
      takeLatest(ACTION_GET_POST_DETAILS, requestGetPostDetails),
      takeLatest(ACTION_ADD_POST, requestAddPost),
      takeLatest(ACTION_UPDATE_POST, requestUpdatePost),
      takeLatest(ACTION_DELETE_POST, requestDeletePost)
    ]);
  }
];
