@@ -1842,10 +1842,7 @@ trait Observable[+T]
1842
1842
* Observable satisfy the predicate; otherwise, `false`
1843
1843
*/
1844
1844
def forall (predicate : T => Boolean ): Observable [Boolean ] = {
1845
- // type mismatch; found : rx.Observable[java.lang.Boolean] required: rx.Observable[_ <: scala.Boolean]
1846
- // new Observable[Boolean](asJavaNotification.all(predicate))
1847
- // it's more fun in Scala:
1848
- this .map(predicate).foldLeft(true )(_ && _)
1845
+ toScalaObservable[java.lang.Boolean ](asJavaObservable.all(predicate)).map(_.booleanValue())
1849
1846
}
1850
1847
1851
1848
/**
@@ -4122,6 +4119,35 @@ trait Observable[+T]
4122
4119
*/
4123
4120
def toArray [U >: T : ClassTag ]: Observable [Array [U ]] = // use U >: T because Array is invariant
4124
4121
toBuffer[U ].map(_.toArray)
4122
+
4123
+ /**
4124
+ * Returns an [[Observable ]] which only emits elements which do not satisfy a predicate.
4125
+ *
4126
+ * @param p the predicate used to test elements.
4127
+ * @return Returns an [[Observable ]] which only emits elements which do not satisfy a predicate.
4128
+ */
4129
+ def filterNot (p : T => Boolean ): Observable [T ] = {
4130
+ filter(! p(_))
4131
+ }
4132
+
4133
+ /**
4134
+ * Return an [[Observable ]] which emits the number of elements in the source [[Observable ]] which satisfy a predicate.
4135
+ *
4136
+ * @param p the predicate used to test elements.
4137
+ * @return an [[Observable ]] which emits the number of elements in the source [[Observable ]] which satisfy a predicate.
4138
+ */
4139
+ def count (p : T => Boolean ): Observable [Int ] = {
4140
+ filter(p).length
4141
+ }
4142
+
4143
+ /**
4144
+ * Return an [[Observable ]] emitting one single `Boolean`, which is `true` if the source [[Observable ]] emits any element, and `false` otherwise.
4145
+ *
4146
+ * @return an [[Observable ]] emitting one single Boolean`, which is `true` if the source [[Observable ]] emits any element, and `false otherwise.
4147
+ */
4148
+ def nonEmpty : Observable [Boolean ] = {
4149
+ isEmpty.map(! _)
4150
+ }
4125
4151
}
4126
4152
4127
4153
/**
0 commit comments