Skip to content

Instantly share code, notes, and snippets.

@CoderJava
Created October 1, 2018 16:27
Show Gist options
  • Select an option

  • Save CoderJava/93ee0a1b2ed7c55eb16f98d134366d38 to your computer and use it in GitHub Desktop.

Select an option

Save CoderJava/93ee0a1b2ed7c55eb16f98d134366d38 to your computer and use it in GitHub Desktop.
Transforming Operator groupBy
public class RxTransformingOperatorGroupBy {
public static void main(String[] args) {
Observable.range(1, 9)
.groupBy(item -> item % 2 == 0 ? "Genap" : "Ganji")
.subscribe(groupObservable -> {
if (groupObservable.getKey().equalsIgnoreCase("Genap")) {
System.out.println("Emit bilangan genap");
System.out.println("List bilangan genap adalah sebagai berikut.");
groupObservable.subscribe(System.out::println);
} else {
System.out.println("Emit bilangan ganjil");
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment