-
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
Operator: CombineLatest #29
Comments
What's the status on this operator? - There is some code, but the tests look a bit different from what I would expect this operator to do. Shouldn't w1.Observer.onNext("1a");
w1.Observer.onCompleted();
w2.Observer.onNext("2a");
w2.Observer.onNext("2b");
w2.Observer.onCompleted();
w3.Observer.onNext("3a");
w3.Observer.onNext("3b");
w3.Observer.onNext("3c");
w3.Observer.onNext("3d");
w3.Observer.onCompleted(); generate "1a2b3a", then "1a2b3b", then "1a2b3c", then "1a2b3d"? Because it starts with the latest values of The current code seems to still "wait" for an |
As I'm reading through this I'm using the following to research the expected behavior: http://blogs.microsoft.co.il/blogs/bnaya/archive/2010/03/10/rx-for-beginners-part-8-combine-latest-expression.aspx
The test case appears to be as follows:
This should result in:
On each Extrapolating that into a unit test I get something like this: @Test
public void testCombineLatestDifferentLengthObservableSequencesWithInterleaving1() {
Observer<String> w = mock(Observer.class);
TestObservable x = new TestObservable();
TestObservable y = new TestObservable();
Observable<String> combineLatestW = Observable.create(combineLatest(y, x, getConcat2StringsCombineLatestFunction()));
combineLatestW.subscribe(w);
/* simulate sending data */
x.Observer.onNext("1");
y.Observer.onNext("a");
x.Observer.onNext("2");
x.Observer.onNext("3");
y.Observer.onNext("b");
x.Observer.onNext("4");
x.Observer.onCompleted();
y.Observer.onCompleted();
/* we should have been called 5 times on the Observer */
InOrder inOrder = inOrder(w);
inOrder.verify(w).onNext("a1");
inOrder.verify(w).onNext("a2");
inOrder.verify(w).onNext("a3");
inOrder.verify(w).onNext("b3");
inOrder.verify(w).onNext("b4");
inOrder.verify(w, times(1)).onCompleted();
} This test fails with current code. So yes, the current implementation is wrong - and it's crazy complicated. I'll take a look at your pull request for this fix (hopefully tomorrow, though I have a lot of meetings so ...) Thank you @jmhofer |
I agree. Your test should work with my pull request as I've added a similar test. Also, I simplified the code a bit, but I wasn't sure how thoroughly I could/should rework it, so I kept the basic structure (I guess the complexity mostly comes from the Zip operator it seems to have been copied from originally). The one thing I'm still unsure of is when the combined stream should complete. That first of your links above says: "the Combine Latest processing will come to end either when one of the stream will complete or throw exception." - However I don't really see a reason why it should complete before all streams are complete. - I haven't found any other specification yet for cross-checking this. |
You can change the implementation to whatever makes sense as I obviously misunderstood the behavior when I implemented this long ago and stole the base functionality from Your last question is a good one. If an For the Another way would be a Rx.Net or RxJS test case if you have access to either of those or someone who does. |
The C# code looks very much like they complete only when all streams are complete (when there are no errors). - That's good, then the pull request code should already handle that correctly. |
Great, then I'll proceed with the review and merge. I appreciate your willingness to dive into this one and deal with that gnarly code. |
So if I understand correctly, synchrononous (blocking) sequences make Observable<String> w = Observable.create(combineLatest(Observable.toObservable("one", "two"), Observable.toObservable(2, 3, 4), combineLatestFunction));
w.subscribe(aObserver);
verify(aObserver, times(1)).onNext("two2");
verify(aObserver, times(1)).onNext("two3");
verify(aObserver, times(1)).onNext("two4"); |
Yes, I think so. - I came to that conclusion, too. "latest" doesn't really make much sense in the synchronous case. |
I updated my pull request: I had previously forgotten to adapt the comments. Also, I cleaned up the code a bit and tried to fix synchronization (it's hard, as always...) |
I have merged pull request #207 to resolve this issue. |
* Issue#15 New optimized implementation of CircularFifoBuffer
* test coverage added + jacoco excludes for benchmark classes * Issue#15 circular fifo bufer optimization (ReactiveX#29) * Issue#15 New optimized implementation of CircularFifoBuffer * Updated documentation * Updated documentation * Updated documentation * Updated documentation * Updated documentation * Updated documentation * Updated documentation * Updated documentation * Updated documentation * Updated documentation * Updated documentation * Move all test reporting to cobertura * Time alignment for decorator test * Additional tests and time alignment in spin loop
http://msdn.microsoft.com/en-us/library/hh211991(v=vs.103).aspx
The text was updated successfully, but these errors were encountered: