@@ -1341,7 +1341,7 @@ class Observable[+T] private[scala] (val asJava: rx.Observable[_ <: T])
1341
1341
val f : Func2 [_ >: T , _ >: U , _ <: (T , U )] = (t : T , u : U ) => (t, u)
1342
1342
Observable [(T , U )](rx.Observable .combineLatest[T , U , (T , U )](this .asJava, that.asJava, f))
1343
1343
}
1344
-
1344
+ // Review completed till here!!!
1345
1345
/**
1346
1346
* Debounces by dropping all values that are followed by newer values before the timeout value expires. The timer resets on each `onNext` call.
1347
1347
*
@@ -1530,6 +1530,7 @@ class Observable[+T] private[scala] (val asJava: rx.Observable[_ <: T])
1530
1530
* @return an Observable that emits only the very first item from the source, or a default value
1531
1531
* if the source Observable completes without emitting any item.
1532
1532
*/
1533
+ // TODO def headOrElse
1533
1534
def firstOrElse [U >: T ](default : => U ): Observable [U ] = {
1534
1535
this .take(1 ).fold[Option [U ]](None )((v : Option [U ], e : U ) => Some (e)).map({
1535
1536
case Some (element) => element
@@ -1546,6 +1547,8 @@ class Observable[+T] private[scala] (val asJava: rx.Observable[_ <: T])
1546
1547
* @return an Observable that emits only the very first item from the source, or none if the
1547
1548
* source Observable completes without emitting a single item.
1548
1549
*/
1550
+ // TODO def head
1551
+ // TODO def tail
1549
1552
def first : Observable [T ] = {
1550
1553
take(1 )
1551
1554
}
@@ -1576,37 +1579,6 @@ class Observable[+T] private[scala] (val asJava: rx.Observable[_ <: T])
1576
1579
Observable [T ](asJava.distinctUntilChanged[U ](keySelector))
1577
1580
}
1578
1581
1579
- /**
1580
- * Returns an Observable that forwards all items emitted from the source Observable that are sequentially
1581
- * distinct according to an equality function.
1582
- *
1583
- * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/distinctUntilChanged.png">
1584
- *
1585
- * @param equality
1586
- * an equality function for deciding whether two emitted items are equal or not
1587
- * @return an Observable of sequentially distinct items
1588
- */
1589
- // def distinctUntilChanged[U](equality: (T, T) => Boolean): Observable[T] = {
1590
- // TODO once https://github.com/Netflix/RxJava/issues/395 is fixed
1591
- // }
1592
-
1593
- /**
1594
- * Returns an Observable that forwards all items emitted from the source Observable that are sequentially
1595
- * distinct according to a key selector function and a comparator.
1596
- *
1597
- * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/distinctUntilChanged.key.png">
1598
- *
1599
- * @param keySelector
1600
- * a function that projects an emitted item to a key value which is used for deciding whether an item is sequentially
1601
- * distinct from another one or not
1602
- * @param equality
1603
- * an equality function for deciding whether two emitted item keys are equal or not
1604
- * @return an Observable of sequentially distinct items
1605
- */
1606
- // def distinctUntilChanged[U](keySelector: T => U, equality: (T, T) => Boolean): Observable[T] = {
1607
- // TODO once https://github.com/Netflix/RxJava/issues/395 is fixed
1608
- // }
1609
-
1610
1582
/**
1611
1583
* Returns an Observable that forwards all distinct items emitted from the source Observable.
1612
1584
*
@@ -1618,20 +1590,6 @@ class Observable[+T] private[scala] (val asJava: rx.Observable[_ <: T])
1618
1590
Observable [T ](asJava.distinct())
1619
1591
}
1620
1592
1621
- /**
1622
- * Returns an Observable that forwards all items emitted from the source Observable that are distinct according
1623
- * to a comparator.
1624
- *
1625
- * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/distinct.png">
1626
- *
1627
- * @param equality
1628
- * an equality function for deciding whether two emitted items are equal or not
1629
- * @return an Observable of distinct items
1630
- */
1631
- // def distinct(equality: (T, T) => Boolean): Observable[T] = {
1632
- // TODO once https://github.com/Netflix/RxJava/issues/395 is fixed
1633
- // }
1634
-
1635
1593
/**
1636
1594
* Returns an Observable that forwards all items emitted from the source Observable that are distinct according
1637
1595
* to a key selector function.
@@ -1673,6 +1631,7 @@ class Observable[+T] private[scala] (val asJava: rx.Observable[_ <: T])
1673
1631
* @return an Observable emitting the number of counted elements of the source Observable
1674
1632
* as its single item.
1675
1633
*/
1634
+ // TODO Both size and length
1676
1635
def length : Observable [Int ] = {
1677
1636
Observable [Integer ](asJava.count()).map(_.intValue())
1678
1637
}
@@ -1868,6 +1827,7 @@ object Observable {
1868
1827
Observable [T ](JObservable .from(args.toIterable.asJava))
1869
1828
}
1870
1829
1830
+ // TODO (SG) documentation
1871
1831
def apply (range : Range ): Observable [Int ] = {
1872
1832
Observable [Int ](JObservable .from(range.toIterable.asJava))
1873
1833
}
@@ -1895,29 +1855,6 @@ object Observable {
1895
1855
def defer [T ](observable : => Observable [T ]): Observable [T ] = {
1896
1856
Observable [T ](JObservable .defer[T ](() => observable.asJava))
1897
1857
}
1898
-
1899
- /**
1900
- * Returns an Observable that emits a single item and then completes.
1901
- *
1902
- * <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/just.png">
1903
- *
1904
- * To convert any object into an Observable that emits that object, pass that object into the
1905
- * `just` method.
1906
- *
1907
- * This is similar to the [[Observable.apply[T](T*)]] method, except that
1908
- * [[Observable.apply[T](T*)]] will convert an `Iterable` object into an Observable that emits
1909
- * each of the items in the Iterable, one at a time, while the `just()` method
1910
- * converts an Iterable into an Observable that emits the entire Iterable as a single item.
1911
- *
1912
- * @param value
1913
- * the item to pass to the [[Observer ]]'s [[Observer.onNext onNext ]] method
1914
- * @tparam T
1915
- * the type of that item
1916
- * @return an Observable that emits a single item and then completes
1917
- */
1918
- def just [T ](value : T ): Observable [T ] = {
1919
- Observable [T ](JObservable .just(value))
1920
- }
1921
1858
1922
1859
/**
1923
1860
* Returns an Observable that never sends any items or notifications to an [[Observer ]].
@@ -1932,25 +1869,6 @@ object Observable {
1932
1869
Observable [Nothing ](JObservable .never())
1933
1870
}
1934
1871
1935
- // TODO also support Scala Futures, but think well before. Do we want to Future and Observable
1936
- // to share a common base interface?
1937
-
1938
- // private because it's not RxScala's responsability to provide this alias
1939
- private type Future [+ T ] = java.util.concurrent.Future [_ <: T ]
1940
-
1941
- def apply [T ](f : Future [T ]): Observable [T ] = {
1942
- Observable [T ](rx.Observable .from(f))
1943
- }
1944
-
1945
- def apply [T ](f : Future [T ], scheduler : Scheduler ): Observable [T ] = {
1946
- val sched : rx.Scheduler = scheduler
1947
- Observable [T ](rx.Observable .from(f, sched))
1948
- }
1949
-
1950
- def apply [T ](f : Future [T ], duration : Duration ): Observable [T ] = {
1951
- Observable [T ](rx.Observable .from(f, duration.length, duration.unit))
1952
- }
1953
-
1954
1872
/**
1955
1873
* Given a Seq of N observables, returns an observable that emits Seqs of N elements each.
1956
1874
* The first emitted Seq will contain the first element of each source observable,
@@ -1959,8 +1877,10 @@ object Observable {
1959
1877
* @param observables
1960
1878
* A Seq of source Observables
1961
1879
* @return an Observable that emits the zipped Seqs
1962
- */
1963
- def zip [T ](observables : Seq [Observable [T ]]): Observable [Seq [T ]] = {
1880
+ */
1881
+ def zip [A ,B ,C ](obA : Observable [A ], obB : Observable [B ], obC : Observable [B ]): Observable [(A , B , C )]
1882
+ // TODO until 6
1883
+ def zip [T ](observables : Observable [T ]* ): Observable [Seq [T ]] = {
1964
1884
val f : FuncN [Seq [T ]] = (args : Seq [java.lang.Object ]) => {
1965
1885
val asSeq : Seq [Object ] = args.toSeq
1966
1886
asSeq.asInstanceOf [Seq [T ]]
@@ -1989,11 +1909,16 @@ object Observable {
1989
1909
Observable [Seq [T ]](o)
1990
1910
}
1991
1911
1992
- def interval (duration : Duration ): Observable [Long ] = {
1993
- (new Observable [java.lang.Long ](JObservable .interval(duration.length, duration.unit))).map(_.longValue())
1994
- }
1995
-
1996
- def interval (duration : Duration , scheduler : Scheduler ): Observable [Long ] = {
1912
+ /**
1913
+ * TODO (SG) ScalaDoc
1914
+ * TODO Provide implicit scheduler:
1915
+ *
1916
+ * def interval(duration: Duration)(implicit scheduler: Scheduler): Observable[Long]
1917
+ * def interval(duration: Duration)(scheduler: Scheduler): Observable[Long]
1918
+ * def interval(scheduler: Scheduler)(duration: Duration): Observable[Long]
1919
+ * def interval(duration: Duration, scheduler: Scheduler): Observable[Long] && def interval(duration: Duration): Observable[Long]
1920
+ */
1921
+ def interval (duration : Duration )(implicit scheduler : Scheduler ): Observable [Long ] = {
1997
1922
(new Observable [java.lang.Long ](JObservable .interval(duration.length, duration.unit, scheduler))).map(_.longValue())
1998
1923
}
1999
1924
0 commit comments