Exemplo n.º 1
0
 /**
  * If the {@link Observable} completes after emitting a single item that matches a given
  * predicate, return that item, otherwise throw an <code>NoSuchElementException</code>.
  *
  * <p><img width="640"
  * src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/B.single.p.png">
  *
  * @param predicate a predicate function to evaluate items emitted by the {@link Observable}
  * @return the single item emitted by the source {@link Observable} that matches the predicate
  * @see <a
  *     href="https://github.com/Netflix/RxJava/wiki/Blocking-Observable-Operators#single-and-singleordefault">RxJava
  *     Wiki: single()</a>
  * @see <a
  *     href="http://msdn.microsoft.com/en-us/library/system.reactive.linq.observable.single.aspx">MSDN:
  *     Observable.Single</a>
  */
 public T single(Func1<? super T, Boolean> predicate) {
   return from(o.single(predicate)).toIterable().iterator().next();
 }
Exemplo n.º 2
0
 /**
  * If the {@link Observable} completes after emitting a single item, return that item, otherwise
  * throw an <code>NoSuchElementException</code>.
  *
  * <p><img width="640"
  * src="https://github.com/Netflix/RxJava/wiki/images/rx-operators/B.single.png">
  *
  * @return the single item emitted by the {@link Observable}
  * @see <a
  *     href="https://github.com/Netflix/RxJava/wiki/Blocking-Observable-Operators#single-and-singleordefault">RxJava
  *     Wiki: single()</a>
  * @see <a
  *     href="http://msdn.microsoft.com/en-us/library/system.reactive.linq.observable.single.aspx">MSDN:
  *     Observable.Single</a>
  */
 public T single() {
   return from(o.single()).toIterable().iterator().next();
 }