Skip to content

Instantly share code, notes, and snippets.

@pyadav
Forked from yongjhih/rx-github.js
Created August 8, 2016 04:10
Show Gist options
  • Select an option

  • Save pyadav/657d0ee88ce56bf4bdab38be1ecf2a36 to your computer and use it in GitHub Desktop.

Select an option

Save pyadav/657d0ee88ce56bf4bdab38be1ecf2a36 to your computer and use it in GitHub Desktop.
function rxfetch(url) {
return rxfetch(url).flatMap(function (response) {
var next = response.headers.get('Link').replace(/<([^<]*)>; rel="next".*/, '$1');
return Rx.Observable.concat(Rx.Observable.just(response), next ? rxfetch3(next) : Rx.Observable.empty());
});
}
rxfetch('https://api.github.com/users/yongjhih/repos')
.map(function (response) { return response.json(); })
.flatMap(function (json) { return Rx.Observable.from(json); })
.map(function (json) { return json.name; })
.subscribe(function (name) {
console.log(name);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment