Last active
August 3, 2017 08:41
-
-
Save cartant/b99bdb7f41b6b9b9c936ae3c8327e588 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