I am using angular 2 and it\'s http component.
I want to call a REST API that will return a list of Elements. The size of that list is limited to 100 entries. If the
Recursion is exactly what the expand operator is for:
let callAndMap = (pageNo) => call({page: pageNo}).map(res => {page: pageNo, data: res.json()}); // map, and save the page number for recursion later.
callAndMap(1)
.expand(obj => (obj.data.meta.hasMore ? callAndMap(obj.page + 1) : Observable.empty()))
//.map(obj => obj.data) // uncomment this line if you need to map back to original response json
.subscribe(callback);