示例#1
0
 /**
  * Returns the first item emitted by a specified {@link Observable} that matches a predicate, or
  * <code>NoSuchElementException</code> if no such item is emitted.
  *
  * @param predicate a predicate function to evaluate items emitted by the {@link Observable}
  * @return the first item emitted by the {@link Observable} that matches the predicate
  * @throws NoSuchElementException if no such items are emitted
  * @see <a
  *     href="https://github.com/Netflix/RxJava/wiki/Blocking-Observable-Operators#first-and-firstordefault">RxJava
  *     Wiki: first()</a>
  * @see <a href="http://msdn.microsoft.com/en-us/library/hh229739.aspx">MSDN: Observable.First</a>
  */
 public T first(Func1<? super T, Boolean> predicate) {
   return from(o.first(predicate)).single();
 }
示例#2
0
 /**
  * Returns the first item emitted by a specified {@link Observable}, or <code>
  * NoSuchElementException</code> if source contains no elements.
  *
  * @return the first item emitted by the source {@link Observable}
  * @throws NoSuchElementException if source contains no elements
  * @see <a
  *     href="https://github.com/Netflix/RxJava/wiki/Blocking-Observable-Operators#first-and-firstordefault">RxJava
  *     Wiki: first()</a>
  * @see <a href="http://msdn.microsoft.com/en-us/library/hh229177.aspx">MSDN: Observable.First</a>
  */
 public T first() {
   return from(o.first()).single();
 }