Skip to content

Instantly share code, notes, and snippets.

@ajcrites
Created February 14, 2018 01:37
Show Gist options
  • Select an option

  • Save ajcrites/5ea10efdec3822e21a8ed1addf97a5cb to your computer and use it in GitHub Desktop.

Select an option

Save ajcrites/5ea10efdec3822e21a8ed1addf97a5cb to your computer and use it in GitHub Desktop.
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