Skip to content

Commit 373f5b3

Browse files
apply review patch
1 parent 06797f8 commit 373f5b3

File tree

1 file changed

+20
-95
lines changed

1 file changed

+20
-95
lines changed

language-adaptors/rxjava-scala/src/main/scala/rx/lang/scala/Observable.scala

Lines changed: 20 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,7 @@ class Observable[+T] private[scala] (val asJava: rx.Observable[_ <: T])
13411341
val f: Func2[_ >: T, _ >: U, _ <: (T, U)] = (t: T, u: U) => (t, u)
13421342
Observable[(T, U)](rx.Observable.combineLatest[T, U, (T, U)](this.asJava, that.asJava, f))
13431343
}
1344-
1344+
// Review completed till here!!!
13451345
/**
13461346
* Debounces by dropping all values that are followed by newer values before the timeout value expires. The timer resets on each `onNext` call.
13471347
*
@@ -1530,6 +1530,7 @@ class Observable[+T] private[scala] (val asJava: rx.Observable[_ <: T])
15301530
* @return an Observable that emits only the very first item from the source, or a default value
15311531
* if the source Observable completes without emitting any item.
15321532
*/
1533+
// TODO def headOrElse
15331534
def firstOrElse[U >: T](default: => U): Observable[U] = {
15341535
this.take(1).fold[Option[U]](None)((v: Option[U], e: U) => Some(e)).map({
15351536
case Some(element) => element
@@ -1546,6 +1547,8 @@ class Observable[+T] private[scala] (val asJava: rx.Observable[_ <: T])
15461547
* @return an Observable that emits only the very first item from the source, or none if the
15471548
* source Observable completes without emitting a single item.
15481549
*/
1550+
// TODO def head
1551+
// TODO def tail
15491552
def first: Observable[T] = {
15501553
take(1)
15511554
}
@@ -1576,37 +1579,6 @@ class Observable[+T] private[scala] (val asJava: rx.Observable[_ <: T])
15761579
Observable[T](asJava.distinctUntilChanged[U](keySelector))
15771580
}
15781581

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-
16101582
/**
16111583
* Returns an Observable that forwards all distinct items emitted from the source Observable.
16121584
*
@@ -1618,20 +1590,6 @@ class Observable[+T] private[scala] (val asJava: rx.Observable[_ <: T])
16181590
Observable[T](asJava.distinct())
16191591
}
16201592

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-
16351593
/**
16361594
* Returns an Observable that forwards all items emitted from the source Observable that are distinct according
16371595
* to a key selector function.
@@ -1673,6 +1631,7 @@ class Observable[+T] private[scala] (val asJava: rx.Observable[_ <: T])
16731631
* @return an Observable emitting the number of counted elements of the source Observable
16741632
* as its single item.
16751633
*/
1634+
//TODO Both size and length
16761635
def length: Observable[Int] = {
16771636
Observable[Integer](asJava.count()).map(_.intValue())
16781637
}
@@ -1868,6 +1827,7 @@ object Observable {
18681827
Observable[T](JObservable.from(args.toIterable.asJava))
18691828
}
18701829

1830+
// TODO (SG) documentation
18711831
def apply(range: Range): Observable[Int] = {
18721832
Observable[Int](JObservable.from(range.toIterable.asJava))
18731833
}
@@ -1895,29 +1855,6 @@ object Observable {
18951855
def defer[T](observable: => Observable[T]): Observable[T] = {
18961856
Observable[T](JObservable.defer[T](() => observable.asJava))
18971857
}
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-
}
19211858

19221859
/**
19231860
* Returns an Observable that never sends any items or notifications to an [[Observer]].
@@ -1932,25 +1869,6 @@ object Observable {
19321869
Observable[Nothing](JObservable.never())
19331870
}
19341871

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-
19541872
/**
19551873
* Given a Seq of N observables, returns an observable that emits Seqs of N elements each.
19561874
* The first emitted Seq will contain the first element of each source observable,
@@ -1959,8 +1877,10 @@ object Observable {
19591877
* @param observables
19601878
* A Seq of source Observables
19611879
* @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]] = {
19641884
val f: FuncN[Seq[T]] = (args: Seq[java.lang.Object]) => {
19651885
val asSeq: Seq[Object] = args.toSeq
19661886
asSeq.asInstanceOf[Seq[T]]
@@ -1989,11 +1909,16 @@ object Observable {
19891909
Observable[Seq[T]](o)
19901910
}
19911911

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] = {
19971922
(new Observable[java.lang.Long](JObservable.interval(duration.length, duration.unit, scheduler))).map(_.longValue())
19981923
}
19991924

0 commit comments

Comments
 (0)