I replaced the action call to Consumer in my code but while subscribing it keeps asking me to cast it to observer
Below is the code
public void fetchSubscriptionPlans(String url, String apiKey, String authToken,
final Consumer<List<ContentDatum>> subscriptionPlans) {
appCMSSubscriptionPlanRest.getPlansById(url,authHeaders).enqueue(new Callback<List<ContentDatum>>() {
@Override
public void onResponse(Call<List<ContentDatum>> call, Response<List<ContentDatum>> response) {
try {
Observable.just(response.body())
.onErrorResumeNext(throwable -> Observable.empty())
.subscribe(subscriptionPlans);
} catch (Exception e) {
Observable.just((List<ContentDatum>) null)
.onErrorResumeNext(throwable -> Observable.empty())
.subscribe(subscriptionPlans);
}
}
@Override
public void onFailure(Call<List<ContentDatum>> call, Throwable t) {
}
});
}
I get the error on .subscribe(subscriptionPlans);
to cast it as .subscribe((Observer<? super List<ContentDatum>>) subscriptionPlans);
What should be correct way?
And on running the code I get the exception
cannot be cast to rx.Observer