Skip to content

Instantly share code, notes, and snippets.

@rubykv
Created March 31, 2022 17:38
Show Gist options
  • Save rubykv/648e93e3512e0c0f8758ee1471b7d72e to your computer and use it in GitHub Desktop.
Save rubykv/648e93e3512e0c0f8758ee1471b7d72e to your computer and use it in GitHub Desktop.
Observable<Integer> observable1 = Observable.just(1, 2, 3, 4, 5);
Consumer<Integer> addValues = (x) -> System.out.println("Adding " + x + " ::" + (x + 2));
Consumer<Integer> subValues = (x) -> System.out.println("Subtracting " + x + " :: " + (x - 1));
observable1.filter(x -> x > 1).subscribe(x -> addValues.accept(x));
observable1.filter(x -> x < 2).subscribe(x -> subValues.accept(x));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment