I am attempting to retrieve all pages until either there are no more pages or a certain limit (let's say 10 pages) is reached.
If I follow this approach:
obs.pipe(expand((page) => {
return service.call(page).nextPage;
}),
take(10),
takeWhile(morePages));
In this case, the take 10 always occurs. However, if I try it like this:
obs.pipe(expand((page) => {
return service.call(page).nextPage;
}),
takeWhile(morePages),
take(10));
it might exceed the limit of 10 calls.
The alternative is to create my own version of takeWhile that includes its own counter. Although I plan to go with this option, I am curious if there is a way to achieve this using standard rxjs methods.