-
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
Reimplement Zip Operator Using Lift [Preview] #785
Reimplement Zip Operator Using Lift [Preview] #785
Conversation
RxJava-pull-requests #704 ABORTED |
@SuppressWarnings("rawtypes") | ||
@Override | ||
public Observer<? super Observable[]> call(final Observer<? super R> observer) { | ||
return new Observer<Observable[]>(observer) { |
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.
If observer is not SafeObserver, there will be a similar issue like #766 ?
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.
No, because counter will stay 1 and won't let any tick() to execute after a completion condition.
Other than the lack of null sentinel, it looks okay. |
Thank you both for the review. |
@Override | ||
public void onError(Throwable e) { | ||
// emit error and shut down | ||
observer.onError(e); |
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.
Sorry for my ambiguous comment.
Here is the test:
@SuppressWarnings("unchecked")
@Test
public void testOnErrorWithInternalObserver() {
Observable<String> w = Observable.zip(
Observable.<Integer> error(new RuntimeException()),
Observable.<Integer> error(new RuntimeException()),
new Func2<Integer,Integer,String>(){
@Override
public String call(Integer t1, Integer t2) {
return t1 + "" + t2;
}
});
final Observer<String> observer = mock(Observer.class);
w.subscribe(new Observer<String>() {
@Override
public void onCompleted() {
observer.onCompleted();
}
@Override
public void onError(Throwable e) {
observer.onError(e);
}
@Override
public void onNext(String t) {
observer.onNext(t);
}
});
verify(observer, times(1)).onError(isA(RuntimeException.class)); // The current implementation will emit 2 errors.
verify(observer, never()).onCompleted();
verify(observer, never()).onNext(any(String.class));
}
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.
The test need to be put in the OperatorZipTest.java
.
Is it possible to lift (2..n)-arity operator ? |
If you're referring to arguments passed into an If you're referring to something like In this particular instance I'm taking the types, creating an return just(new Observable<?>[] { o1, o2, o3 }).lift(new OperatorZip<R>(zipFunction)); If the specific types wanted to be retained, then the I think of this somewhat like currying, where an |
RxJava-pull-requests #716 ABORTED |
- Use new lift operator implement and non-blocking synchronization approach. - I have had the concurrency model reviewed by some colleagues and all unit tests are passing but further review is justified and welcome.
Similar to Observers.
Reimplement Zip Operator Using Lift [Preview]
RxJava-pull-requests #732 FAILURE |
A preview of a re-implementation of the
zip
operator.This re-implements the
zip
operator but not yet thezipIterable
so those unit tests are still failing. I'm submitting early to get a code review and will finish thezipIterable
sometime early next week.I have already had the concurrency model reviewed by two others and all unit tests are passing but further review is justified and welcome.
The performance of this implementation (without doing any profiling) has risen from 1.42m ops/second on v0.16 to 1.67m ops/second as measured on my machine for the simple test
Observable.zip(from(1), from(1), {a, b -> a+b})
and 31k ops/second to 63k ops/second forObservable.zip(range(0, 100), range(100, 200), {a, b -> a+b})
.