-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more operators to RxScala #1265
Conversation
… => Observable[Any])'
RxJava-pull-requests #1160 FAILURE |
Thanks @zsxwing. Probably a good idea to look for more places where we can use |
The code looks fine to me. Can't see quickly howthe cloudbees failure connected to the code in this pull request, though. |
}).toMap | ||
}).toMap ++ List.iterate("Observable[_ <: T]", 9)(s => s + ", Observable[_ <: T]").map( | ||
// amb 2-9 | ||
"amb(" + _ + ")" -> "[unnecessary because we can use `o1 amb o2` instead or `amb(List(o1, o2, o3, ...)`]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, there's no such thing as o1 amb o2
. You could add this. And then, maybe no varargs, but Iterable for the one in the companion object, because the typical use case of 2 Observables would be covered already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already have this instance method: def amb[U >: T](that: Observable[U]): Observable[U]
in RxScala
The two Java methods public final <TClosing> Observable<Observable<T>> window(Func0<? extends Observable<? extends TClosing>> closingSelector)
public final <U> Observable<Observable<T>> window(Observable<U> boundary) have very different semantics, and both of them are useful and should be present in the RxScala. Since we cannot have an overload which takes an The same applies to |
Of course, main pitfall of |
In RxJava, it's
Looks |
OK. |
RxJava-pull-requests #1162 SUCCESS |
I think the javadoc does not correspond to the implementation... |
…Any])" and "buffer(Observable[Any])""; Remove the cast for "window(=> Observable[Any])"
The only place I found is "buffer". Already updated it. |
Cool. |
RxJava-pull-requests #1173 SUCCESS |
@DavidMGross, could you help improve the javadoc for |
Will do. On Wed, May 28, 2014 at 8:43 AM, Shixiong Zhu [email protected]:
David M. Gross |
Is this ready for merging? |
Looks good to go to me. |
Add more operators to RxScala
IMHO, it makes more sense to say that the javadoc is correct, but the implementation of /**
* Returns an Observable that emits windows of items it collects from the source Observable. The resulting
* Observable emits connected, non-overlapping windows. It emits the current window and opens a new one when
* the Observable produced by the specified {@code closingSelector} emits an item. The {@code closingSelector}
* then creates a new Observable to generate the closer of the next window.
* <p>
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/window1.png">
*
* @param closingSelector
* a {@link Func0} that produces an Observable for every window created. When this Observable
* emits an item, {@code window()} emits the associated window and begins a new one.
* @return an Observable that emits connected, non-overlapping windows of items from the source Observable
* when {@code closingSelector} emits an item
* @see <a href="https://github.com/Netflix/RxJava/wiki/Transforming-Observables#wiki-window">RxJava Wiki: window()</a>
*/
public final <TClosing> Observable<Observable<T>> window(Func0<? extends Observable<? extends TClosing>> closingSelector)
/**
* Returns an Observable that emits non-overlapping windows of items it collects from the source Observable
* where the boundary of each window is determined by the items emitted from a specified boundary-governing
* Observable.
* <p>
* <img width="640" src="https://raw.github.com/wiki/Netflix/RxJava/images/rx-operators/window8.png">
*
* @param <U>
* the window element type (ignored)
* @param boundary
* an Observable whose emitted items close and open windows
* @return an Observable that emits non-overlapping windows of items it collects from the source Observable
* where the boundary of each window is determined by the items emitted from the {@code boundary} Observable
*/
public final <U> Observable<Observable<T>> window(Observable<U> boundary) @headinthebox @benjchristensen what do you think? |
I think public final <A, B> Observable<Observable<T>> window(Func0<? extends Observable<? extends A>> firstClosingSelector, Func1<? super T, ? extends Observable<? extends B>> closingSelector) is better. However, from MSDN: http://msdn.microsoft.com/en-us/library/hh229909(v=vs.103).aspx , the current implementation in RxJava is same as Rx.Net. |
The commits explain this PR.
In addition, the reason that I changed
window(closings: () => Observable[Any])
towindow(boundary: => Observable[Any])
iswindow(boundary: => Observable[Any])
can support both two overloadswindow(Observable[U])
andwindow(Func0[_ <: Observable[_ <: TClosing]])
in RxJava.