determine whether an Observable emits a particular item or not
Pass the Contains operator a particular item, and the Observable it returns will emit
true
if that item is emitted by the source Observable, or false
if the source Observable terminates without emitting that item.
A related operator, IsEmpty returns an Observable that emits
true
if and only if the source Observable completes without emitting any items. It emits false
if the source Observable emits an item.
--------------------------------------------------------------------------
List<Integer> list2 = new ArrayList<>();
list2.add(1);
list2.add(2);
list2.add(3);
list2.add(4);
list2.add(5);
Observable.fromIterable(list2).contains(3).subscribe(System.out::println);
--------------------------------------------------------------------------------
No comments:
Post a Comment