@@ -1842,10 +1842,7 @@ trait Observable[+T]
18421842 * Observable satisfy the predicate; otherwise, `false`
18431843 */
18441844 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())
18491846 }
18501847
18511848 /**
@@ -4122,6 +4119,35 @@ trait Observable[+T]
41224119 */
41234120 def toArray [U >: T : ClassTag ]: Observable [Array [U ]] = // use U >: T because Array is invariant
41244121 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+ }
41254151}
41264152
41274153/**
0 commit comments