Last active
March 28, 2020 10:57
-
-
Save Djuki/26ce196615004a53ed3fce6f533996bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { FETCH_MORE_BRANCHES, successFetchBranches } from '../actions'; | |
import { ofType } from 'redux-observable'; | |
import { EMPTY, of } from 'rxjs'; | |
import { ajax } from 'rxjs/ajax'; | |
import { mergeMap, map, catchError } from 'rxjs/operators'; | |
import tokenHeader from '../../common/helpers/token'; | |
import { showAlertBox } from '../../common/layout'; | |
const fetchLoadMoreBranchesEpic = action$ => { | |
return action$.pipe( | |
ofType(FETCH_MORE_BRANCHES), | |
mergeMap(({ identityId, nextPage }) => { | |
if (nextPage === false) { | |
return EMPTY; | |
} | |
return ajax.post(`/app/auto/repos/branches/${identityId}`, { nextPage }, tokenHeader()).pipe( | |
map(data => successFetchBranches(data.response.branches, data.response.nextPage)), | |
catchError(error => of(showAlertBox('danger', error.response.message))) | |
); | |
}) | |
); | |
}; | |
export default fetchLoadMoreBranchesEpic; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment