Let's take this observable:
Observable<List<UserProfile>> findUser =service.getUserProfiles()
How can I transform it so it returns the first element as an Observable (and not an Observable list just containing the first element). I tried first()
and takeFirst()
but it still returns a list.
Map it!
Observable<List<UserProfile>> findUser = service.getUserProfiles();
Observable<UserProfile> firstUser = findUser
.filter(list -> !list.isEmpty())
.map(list -> list.get(0));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With