Amrmsmb
Amrmsmb

Reputation: 1

add subscriber to Single observed value

I would like to know how can I add the subscriber for single as shown below in the code. when i try to add .subscribe() or .blockingsubscribe() the autocomplete in eclise does not show them

code:

Single<List<List<Person>>> singles = Single.just(Main.getPersons());
    singles
    .observeOn(Schedulers.io())
    .map(x->System.out.println(x.size()))

Upvotes: 1

Views: 49

Answers (2)

akarnokd
akarnokd

Reputation: 69997

You are using the wrong lambda and it throws off your IDE. Try this:

Single<List<List<Person>>> singles = Single.just(Main.getPersons());
singles
.observeOn(Schedulers.io())
.doOnSuccess(x -> System.out.println(x.size()))
.  // <---------------------------------------- now it should bring up the autocomplete

Upvotes: 1

taygetos
taygetos

Reputation: 3040

Your map function should return something that you want to subscribe on:

.map(x -> {
    System.out.println(x.size());
    return ???;
 });

Upvotes: 1

Related Questions