I want to get emitted items from an Observable stream.
I can do this in Collection streams with the following code:
List<String> items = Arrays.asList("a", "b");
String result = items.stream().filter(i -> i.equals("a")).findFirst().orElse("");
I want to do the same thing with RxJava Observable. I tried this but it returns an Observable<String>
not a String
.
Observable<String> result2 = Observable.from(items).filter(i -> i.equals("a")).firstOrDefault("");