Skip to content

Instantly share code, notes, and snippets.

@cartant
Last active May 13, 2018 07:10
Show Gist options
  • Select an option

  • Save cartant/a10f451ac7df99573454c3623926c9ec to your computer and use it in GitHub Desktop.

Select an option

Save cartant/a10f451ac7df99573454c3623926c9ec to your computer and use it in GitHub Desktop.
import { EMPTY, Observable, zip } from "rxjs";
import { expand, map } from "rxjs/operators";
import { get } from "./github";
function pages<T>(
uri: string,
notifier: Observable<any>
): Observable<T[]> {
return get<T[]>(uri).pipe(
expand(({ next }) => {
if (next) {
return zip(notifier, get(next)).pipe(
map(([, response]) => response)
);
}
return EMPTY;
}),
map(({ content }) => content)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment