ElementAt
emit only item n emitted by an Observable
TheElementAt
operator pulls an item located at a specified index location in the sequence of items emitted by the source Observable and emits that item as its own sole emission.-----------------------------------------------------------------------------
List<String> list = new ArrayList<>();
list.add("List-1");
list.add("List-2");
list.add("List-3");
list.add("List-4");
list.add("List-5");
Observable.fromIterable(list).elementAt(2).subscribe(System.out::println);
-------------------------------------------------------------------------------------------------------------
or Default
Observable.fromIterable(list).elementAt(15, list.get(1)).subscribe(System.out::println);
----------------------------------------------------------------------------------------------------------------
or Error
Observable.fromIterable(list).elementAtOrError(15).subscribe(System.out::println);
-----------------------------------------------------------------------------
22
No comments:
Post a Comment