Skip to content

Instantly share code, notes, and snippets.

@seyedjafariy
Created March 18, 2018 06:15
Show Gist options
  • Save seyedjafariy/ecf346e3f9f6532effdddb67ca6aafe4 to your computer and use it in GitHub Desktop.
Save seyedjafariy/ecf346e3f9f6532effdddb67ca6aafe4 to your computer and use it in GitHub Desktop.
Reactive Operators Example-2
List<Integer> ints = Arrays.asList(1, 4, 7, 5, 1, 5, 4, 5, 1, 7);
Observable.fromIterable(ints)
.distinct()
.filter(integer-> integer % 2 == 0)
.subscribe();
Observable.create(new ObservableOnSubscribe<String>() {
@Override
public void subscribe(ObservableEmitter<String> e) throws Exception {
for (int i = 0; i > 10; i++) {
e.onNext("example No:." + i);
}
e.onComplete();
}
}).toList()
.map(new Function<List<String>, String>() {
@Override
public String apply(List<String> strings) throws Exception {
return strings.toString();
}
}).subscribe();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment