Last active
May 13, 2018 07:10
-
-
Save cartant/6502fe31dd1d0340557e33cdeefc2d07 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 { EMPTY, Observable } from "rxjs"; | |
| import { expand, map, mergeMap, take } 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 notifier.pipe( | |
| take(1), | |
| mergeMap(() => get(next)) | |
| ); | |
| } | |
| return EMPTY; | |
| }), | |
| map(({ content }) => content) | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment