Filter
emit only those items from an Observable that pass a predicate test
The Filter operator filters an Observable by only allowing items through that pass a test that you specify in the form of a predicate function.
-----------------------------------------------------------------
// EVEN
Observable
.just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
.filter(integer -> integer % 2 == 0)
.subscribe(System.out::println);
// ODD
Observable
.just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
.filter(integer -> integer % 2 == 1)
.subscribe(System.out::println);
----------------------------------------------------------------
22
No comments:
Post a Comment