forked from wednesday-solutions/react-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsaga.js
19 lines (18 loc) · 710 Bytes
/
saga.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { put, call, takeLatest } from 'redux-saga/effects';
import { getRepos } from '@services/repoApi';
import { homeContainerTypes, homeContainerCreators } from './reducer';
const { REQUEST_GET_GITHUB_REPOS } = homeContainerTypes;
const { successGetGithubRepos, failureGetGithubRepos } = homeContainerCreators;
export function* getGithubRepos(action) {
const response = yield call(getRepos, action.repoName);
const { data, ok } = response;
if (ok) {
yield put(successGetGithubRepos(data));
} else {
yield put(failureGetGithubRepos(data));
}
}
// Individual exports for testing
export default function* homeContainerSaga() {
yield takeLatest(REQUEST_GET_GITHUB_REPOS, getGithubRepos);
}