-
Notifications
You must be signed in to change notification settings - Fork 112
Closed
Labels
Description
RxJava changed collect
to Observable<R> collect(Func0<R> stateFactory, final Action2<R, ? super T> collector)
in https://github.com/ReactiveX/RxJava/pull/1884/files#diff-c3bbc6e9e497930d46361b0b8140431cR3471 to fix ReactiveX/RxJava#1831
RxScala has the same issue and needs a similar operator too. ReactiveX/RxJava#1835 is a great fix for RxScala but has an ambiguity issue: ReactiveX/RxJava#1884
To solve this issue, here are 3 options:
-
Add
collect
into RxScala to call RxJava'scollect
. However, RxScala has a same name method:def collect[R](pf: PartialFunction[T, R]): Observable[R]
. It may confuse people because they are totally different. -
Change
foldLeft
to
def foldLeft[R](initialValue: => R)(accumulator: (R, T) => R): Observable[R] = {
val func = new rx.functions.Func0[Array[R]] {
override def call(): Array[R] = Array(initialValue)
}
toScalaObservable[R](asJavaObservable.collect(func, new Action2[Array[R],T]{
def call(t1: Array[R], t2: T): Unit = {
t1(0) = accumulator(t1(0),t2)
}
}).map(_(0)))
}
- Give another name for RxJava
collect
.
I prefer 3). Any suggestion for the new name?
nemccarthy