@@ -2690,6 +2690,57 @@ trait Observable[+T]
2690
2690
toScalaObservable[T ](asJavaObservable.delay(delay.length, delay.unit, scheduler))
2691
2691
}
2692
2692
2693
+ /**
2694
+ * Returns an Observable that delays the emissions of the source Observable via another Observable on a
2695
+ * per-item basis.
2696
+ * <p>
2697
+ * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/delay.o.png">
2698
+ * <p>
2699
+ * Note: the resulting Observable will immediately propagate any `onError` notification
2700
+ * from the source Observable.
2701
+ *
2702
+ * @param itemDelay a function that returns an Observable for each item emitted by the source Observable, which is
2703
+ * then used to delay the emission of that item by the resulting Observable until the Observable
2704
+ * returned from `itemDelay` emits an item
2705
+ * @return an Observable that delays the emissions of the source Observable via another Observable on a per-item basis
2706
+ */
2707
+ def delay (itemDelay : T => Observable [Any ]): Observable [T ] = {
2708
+ val itemDelayJava = new Func1 [T , rx.Observable [Any ]] {
2709
+ override def call (t : T ): rx.Observable [Any ] =
2710
+ itemDelay(t).asJavaObservable.asInstanceOf [rx.Observable [Any ]]
2711
+ }
2712
+ toScalaObservable[T ](asJavaObservable.delay[Any ](itemDelayJava))
2713
+ }
2714
+
2715
+ /**
2716
+ * Returns an Observable that delays the subscription to and emissions from the souce Observable via another
2717
+ * Observable on a per-item basis.
2718
+ * <p>
2719
+ * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/delay.oo.png">
2720
+ * <p>
2721
+ * Note: the resulting Observable will immediately propagate any `onError` notification
2722
+ * from the source Observable.
2723
+ *
2724
+ * @param subscriptionDelay a function that returns an Observable that triggers the subscription to the source Observable
2725
+ * once it emits any item
2726
+ * @param itemDelay a function that returns an Observable for each item emitted by the source Observable, which is
2727
+ * then used to delay the emission of that item by the resulting Observable until the Observable
2728
+ * returned from `itemDelay` emits an item
2729
+ * @return an Observable that delays the subscription and emissions of the source Observable via another
2730
+ * Observable on a per-item basis
2731
+ */
2732
+ def delay (subscriptionDelay : () => Observable [Any ], itemDelay : T => Observable [Any ]): Observable [T ] = {
2733
+ val subscriptionDelayJava = new Func0 [rx.Observable [Any ]] {
2734
+ override def call (): rx.Observable [Any ] =
2735
+ subscriptionDelay().asJavaObservable.asInstanceOf [rx.Observable [Any ]]
2736
+ }
2737
+ val itemDelayJava = new Func1 [T , rx.Observable [Any ]] {
2738
+ override def call (t : T ): rx.Observable [Any ] =
2739
+ itemDelay(t).asJavaObservable.asInstanceOf [rx.Observable [Any ]]
2740
+ }
2741
+ toScalaObservable[T ](asJavaObservable.delay[Any , Any ](subscriptionDelayJava, itemDelayJava))
2742
+ }
2743
+
2693
2744
/**
2694
2745
* Return an Observable that delays the subscription to the source Observable by a given amount of time.
2695
2746
*
0 commit comments