Reputation: 73
Declaration
@GET("api/Game/SearchGames")
Observable<List<GameModel>> searchGames();
This is the network call
public static Observable<List<GameModel>> searchGames () {
VersusAPI client = VersusServiceGenerator.createService(VersusAPI.class);
Observable<List<GameModel>> ob = client.searchGames();
return ob;
}
Here is where I implement.
mAdapterMyGames = new RecyclerViewAdapter(searchGames());
searchGames()
returns rx.Observable<java.util.list<GameModel>>
. How do I change that to only java.util.list<GameModel>
?
Upvotes: 1
Views: 57
Reputation: 20258
You don't properly understand what is an Observable
.
It is an object, to which You can subscribe()
to get the result of it's operation. Usually, only when subscribing to an Observable
it starts and you can get the result inside Subscriber
's onNext()
function.
So in your case:
Observable
.Look for the result inside this subscriber's onNext
function.
searchGames().subscribe(new new Subscriber<List<GameModel>>() {
@Override
public void onNext(List<GameModel> gameModels) {
//TODO make sth useful with models
}
@Override
public void onCompleted() { }
@Override
public void onError(Throwable e) { }
)
Upvotes: 1