Current code
Observable.from(listMovie)//list of movie
.flatMap(new Func1<Movie, Observable<FavMovieRes>>() {
@Override
public Observable<FavMovieRes> call(Movie movie) {
return moviesAPI.makeMovieFav(userId),
sessionId, new MakeMovieFav("movie", movie.getId(), movie.isFavList()));
}
})
.subscribe(new Subscriber<FavMovieRes>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(FavMovieRes favMovieRes) {
}
});
In above code I am passing Movie object list to the Observable and perform an operation on each movie instance in list when result gets from the API I want to change some database regarding that movie instance how can I get each Movie instance in OnNext() as well as onError method of subscribe method. what I want is
Observable.from(listMovie)
.flatMap(new Func1<Movie, Observable<FavMovieRes>>() {
@Override
public Observable<FavMovieRes> call(Movie movie) {
return moviesAPI.makeMovieFav(String.valueOf(SharedPreferenceDataManager.getUserId(SyncFavListPeriodicTask.this)), SharedPreferenceDataManager.getSessionId(SyncFavListPeriodicTask.this), new MakeMovieFav("movie", movie.getId(), movie.isFavList()));
}
}).subscribe(new Subscriber<FavMovieRes>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e,Movie movie) {//or MakeMovieFav makeMovieFav
}
@Override
public void onNext(FavMovieRes favMovieRes,Movie movie) {//or MakeMovieFav makeMovieFav
}
});