count the number of items emitted by the source Observable and emit only this value
The Count operator transforms an Observable that emits items into an Observable that emits a single value that represents the number of items emitted by the source Observable.
If the source Observable terminates with an error, Count will pass this error notification along without emitting an item first. If the source Observable does not terminate at all, Count will neither emit an item nor terminate.
---------------------------------------------------------------
List<Integer> list2 = new ArrayList<>();
list2.add(1);
list2.add(2);
list2.add(7);
list2.add(8);
list2.add(8);
list2.add(9);
list2.add(10);
list2.add(3);
list2.add(11);
list2.add(4);
list2.add(5);
list2.add(5);
list2.add(6);
list2.add(11);
list2.add(12);
Observable.fromIterable(list2).count().subscribe(System.out::println);
---------------------------------------------------------------
22
No comments:
Post a Comment