@@ -2305,6 +2305,65 @@ trait Observable[+T]
2305
2305
def delaySubscription (delay : Duration , scheduler : Scheduler ): Observable [T ] = {
2306
2306
toScalaObservable[T ](asJavaObservable.delaySubscription(delay.length, delay.unit, scheduler))
2307
2307
}
2308
+
2309
+ /**
2310
+ * Returns an Observable that emits the single item at a specified index in a sequence of emissions from a
2311
+ * source Observbable.
2312
+ *
2313
+ * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/elementAt.png">
2314
+ *
2315
+ * @param index
2316
+ * the zero-based index of the item to retrieve
2317
+ * @return an Observable that emits a single item: the item at the specified position in the sequence of
2318
+ * those emitted by the source Observable
2319
+ * @throws IndexOutOfBoundsException
2320
+ * if index is greater than or equal to the number of items emitted by the source
2321
+ * Observable
2322
+ * @throws IndexOutOfBoundsException
2323
+ * if index is less than 0
2324
+ * @see `Observable.elementAt`
2325
+ */
2326
+ def apply (index : Int ): Observable [T ] = elementAt(index)
2327
+
2328
+ /**
2329
+ * Returns an Observable that emits the single item at a specified index in a sequence of emissions from a
2330
+ * source Observbable.
2331
+ *
2332
+ * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/elementAt.png">
2333
+ *
2334
+ * @param index
2335
+ * the zero-based index of the item to retrieve
2336
+ * @return an Observable that emits a single item: the item at the specified position in the sequence of
2337
+ * those emitted by the source Observable
2338
+ * @throws IndexOutOfBoundsException
2339
+ * if index is greater than or equal to the number of items emitted by the source
2340
+ * Observable
2341
+ * @throws IndexOutOfBoundsException
2342
+ * if index is less than 0
2343
+ */
2344
+ def elementAt (index : Int ): Observable [T ] = {
2345
+ toScalaObservable[T ](asJavaObservable.elementAt(index))
2346
+ }
2347
+
2348
+ /**
2349
+ * Returns an Observable that emits the item found at a specified index in a sequence of emissions from a
2350
+ * source Observable, or a default item if that index is out of range.
2351
+ *
2352
+ * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/elementAtOrDefault.png">
2353
+ *
2354
+ * @param index
2355
+ * the zero-based index of the item to retrieve
2356
+ * @param defaultValue
2357
+ * the default item
2358
+ * @return an Observable that emits the item at the specified position in the sequence emitted by the source
2359
+ * Observable, or the default item if that index is outside the bounds of the source sequence
2360
+ * @throws IndexOutOfBoundsException
2361
+ * if {@code index} is less than 0
2362
+ */
2363
+ def elementAtOrDefault [U >: T ](index : Int , default : U ): Observable [U ] = {
2364
+ val thisJava = asJavaObservable.asInstanceOf [rx.Observable [U ]]
2365
+ toScalaObservable[U ](thisJava.elementAtOrDefault(index, default))
2366
+ }
2308
2367
}
2309
2368
2310
2369
/**
0 commit comments