Last active
August 3, 2017 08:41
-
-
Save cartant/5e6a77d2f1d287be3b5eeb5a7a364894 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { Observable } from 'rxjs/Observable'; | |
import { ajax } from 'rxjs/observable/dom/ajax'; | |
const getRepos = action$ => | |
action$.ofType('REPOS_REQUEST') | |
.map(action => action.payload.user) | |
.switchMap(user => ajax.getJSON(`https://api.notgithub.com/users/${user}/repos`)) | |
.map(repos => { type: 'REPOS_RESPONSE', payload: { repos } }) | |
.catch(error => Observable.of({ type: 'REPOS_ERROR' })) | |
.tag('getRepos'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment