I use RxBinding
and I have a case where I make use of RxTextView
's textChangeEvents()
I filter them and pass them to switchMap()
where I execute a network request (using Retrofit
) to an endpoint based on another value.
tl;dr :
switchMap(new Func1<TextViewTextChangeEvent, Observable<List<String>>>() {
@Override
public Observable<List<String>> call(TextViewTextChangeEvent textViewTextChangeEvent) {
switch (visibleTab) {
case TAGS:
return presenter.executeSearchPostsByTag(searchBarText, String.valueOf(0));
case PEOPLE:
return presenter.executeSearchPostsByPeople(searchBarText, String.valueOf(0));
case COMPANIES:
return presenter.executeSearchPostsByCompanies(searchBarText, String.valueOf(0));
case JOBS:
return presenter.executeSearchPostsByJobs(searchBarText, String.valueOf(0));
default:
return presenter.executeSearchPostsByTag(searchBarText, String.valueOf(0));
}
}
})
but I can't have as a return type : Observable<List<String>>
since I receive a different object from each request.
How should I deal with such a case ?