@@ -3692,6 +3692,48 @@ trait Observable[+T]
3692
3692
def nest : Observable [Observable [T ]] = {
3693
3693
toScalaObservable(asJavaObservable.nest).map(toScalaObservable[T ](_))
3694
3694
}
3695
+
3696
+ /**
3697
+ * Subscribes to the [[Observable ]] and receives notifications for each element.
3698
+ *
3699
+ * Alias to `subscribe(T => Unit)`.
3700
+ *
3701
+ * @param onNext function to execute for each item.
3702
+ * @throws IllegalArgumentException if `onNext` is null
3703
+ * @since 0.19
3704
+ */
3705
+ def foreach (onNext : T => Unit ): Unit = {
3706
+ asJavaObservable.subscribe(onNext)
3707
+ }
3708
+
3709
+ /**
3710
+ * Subscribes to the [[Observable ]] and receives notifications for each element and error events.
3711
+ *
3712
+ * Alias to `subscribe(T => Unit, Throwable => Unit)`.
3713
+ *
3714
+ * @param onNext function to execute for each item.
3715
+ * @param onError function to execute when an error is emitted.
3716
+ * @throws IllegalArgumentException if `onNext` is null, or if `onError` is null
3717
+ * @since 0.19
3718
+ */
3719
+ def foreach (onNext : T => Unit , onError : Throwable => Unit ): Unit = {
3720
+ asJavaObservable.subscribe(onNext, onError)
3721
+ }
3722
+
3723
+ /**
3724
+ * Subscribes to the [[Observable ]] and receives notifications for each element and the terminal events.
3725
+ *
3726
+ * Alias to `subscribe(T => Unit, Throwable => Unit, () => Unit)`.
3727
+ *
3728
+ * @param onNext function to execute for each item.
3729
+ * @param onError function to execute when an error is emitted.
3730
+ * @param onComplete function to execute when completion is signalled.
3731
+ * @throws IllegalArgumentException if `onNext` is null, or if `onError` is null, or if `onComplete` is null
3732
+ * @since 0.19
3733
+ */
3734
+ def foreach (onNext : T => Unit , onError : Throwable => Unit , onComplete : () => Unit ): Unit = {
3735
+ asJavaObservable.subscribe(onNext, onError, onComplete)
3736
+ }
3695
3737
}
3696
3738
3697
3739
/**
0 commit comments