I'd basically like to implement an observable pool consumer.
So, a service makes an http call to retrieve a number of results and then a component is consuming those results one by one. When the service detects that is running out of results it will make a call again to the server for a number of new results.
I started trying to make single http calls and subscribe and unsubscribe every time, but it seems quite messy and confusing.
I'd like something like this:
this.http
.post(API, postData)
.map((response: Response) => response.json())
.subscribe(data => this.saveData(data))
.repeat(when_certain_condition)
Is there any way to achieve this? I read about repeat but it seems like you need to provide the value to be repeated, so it doesn´t seem like the way to go.
Any ideas? Thanks