Created
February 14, 2018 01:37
-
-
Save ajcrites/5ea10efdec3822e21a8ed1addf97a5cb 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 { request } from 'universal-rxjs-ajax'; | |
| import { concatMap, map, filter, defaultIfEmpty } from 'rxjs/operators'; | |
| const pluck = (...args: string[]) => map(val => args.reduce((props, propName) => { | |
| props[propName] = val[propName]; | |
| return props; | |
| }, {})); | |
| request({ url: 'https://api.github.com/users/ajcrites/repos', method: 'GET' }).pipe( | |
| concatMap(({ response }) => response), | |
| filter(({ stargazers_count }) => !!stargazers_count), | |
| pluck('name', 'stargazers_count'), | |
| defaultIfEmpty('No Stargazers Yet. Keep reaching!'), | |
| ).subscribe(console.log); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment