With RxJava (without Retrolambda), I would like to do some API calls and complete my data with it. My incomplete object is a 'TvShow' with a list of object 'Season'. This 'Season' is empty and I need to complete it with episodes.
Observable<TvShow> getDataTVShow(long idTvShow)
//get TvShow with empty seasons (except season number)
Observable<Season> getDataSeason(long idTvShow, int seasonNumber);
//get one complete season with episodes
So I want to:
- Get my 'TvShow' object (OK)
- Iterate over seasons (List <\Season>) from my 'TvShow' object and do for each season an API call to get my season fully completed and update my 'old' season in the list.
- Then once we have all we need, persist data into the database (subscriber part)
Until now, I only have :
Observable<TvShow> = apiService.getDataTvShow(idTvShow)
I need now to iterate over seasons, I tried to use operator 'map' to switch from 'TvShow' object to my list of seasons (tvShow.getSeasons()) but I'm not sure to be in the good way. Beside that, I know 'doOnNext' will be used to update my 'old' season, that's it.
I tried to work with this good example: Handling lists with RxJava and Retrofit in android but I'm still stuck :(
If you can help me solve this problem, it would be great :)