@@ -77,6 +77,7 @@ import collection.JavaConversions._
7777 */
7878trait Observable [+ T ]
7979{
80+ import scala .collection .JavaConverters ._
8081 import scala .collection .Seq
8182 import scala .concurrent .duration .{Duration , TimeUnit }
8283 import rx .functions ._
@@ -238,6 +239,65 @@ trait Observable[+T]
238239 toScalaObservable(rx.Observable .concat(o1, o2))
239240 }
240241
242+ /**
243+ * Returns an Observable that emits a specified item before it begins to emit items emitted by the source Observable.
244+ * <p>
245+ * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/startWith.png">
246+ *
247+ * @param elem the item to emit
248+ * @return an Observable that emits the specified item before it begins to emit items emitted by the source Observable
249+ */
250+ def + [U >: T ](elem : U ): Observable [U ] = {
251+ val thisJava = this .asJavaObservable.asInstanceOf [rx.Observable [U ]]
252+ toScalaObservable(thisJava.startWith(elem))
253+ }
254+
255+ /**
256+ * Returns an Observable that emits the items in a specified `Observable` before it begins to emit
257+ * items emitted by the source Observable.
258+ * <p>
259+ * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/startWith.o.png">
260+ *
261+ * @param that an Observable that contains the items you want the modified Observable to emit first
262+ * @return an Observable that emits the items in the specified `Observable` and then emits the items
263+ * emitted by the source Observable
264+ */
265+ def startWith [U >: T ](that : Observable [U ]): Observable [U ] = {
266+ val thisJava = this .asJavaObservable.asInstanceOf [rx.Observable [U ]]
267+ val thatJava = that.asJavaObservable.asInstanceOf [rx.Observable [U ]]
268+ toScalaObservable(thisJava.startWith(thatJava))
269+ }
270+
271+ /**
272+ * Returns an Observable that emits the items in a specified `Iterable` before it begins to emit items
273+ * emitted by the source Observable.
274+ * <p>
275+ * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/startWith.png">
276+ *
277+ * @param iterable an Iterable that contains the items you want the modified Observable to emit first
278+ * @return an Observable that emits the items in the specified `Iterable` and then emits the items
279+ * emitted by the source Observable
280+ */
281+ def startWith [U >: T ](iterable : Iterable [U ]): Observable [U ] = {
282+ val thisJava = this .asJavaObservable.asInstanceOf [rx.Observable [U ]]
283+ toScalaObservable(thisJava.startWith(iterable.asJava))
284+ }
285+
286+ /**
287+ * Returns an Observable that emits the items in a specified `Iterable`, on a specified `Scheduler`, before it begins to emit items emitted by the source Observable.
288+ * <p>
289+ * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/startWith.s.png">
290+ *
291+ * @param iterable an Iterable that contains the items you want the modified Observable to emit first
292+ * @param scheduler the Scheduler to emit the prepended values on
293+ * @return an Observable that emits the items in the specified `Iterable`, on a specified `Scheduler`, and then emits the items
294+ * emitted by the source Observable
295+ */
296+ def startWith [U >: T ](iterable : Iterable [U ], scheduler : Scheduler ): Observable [U ] = {
297+ val thisJava = this .asJavaObservable.asInstanceOf [rx.Observable [U ]]
298+ toScalaObservable(thisJava.startWith(iterable.asJava, scalaSchedulerToJavaScheduler(scheduler)))
299+ }
300+
241301 /**
242302 * Returns an Observable that emits the items emitted by several Observables, one after the
243303 * other.
0 commit comments