-
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 doOnSubscribe for Single #3741
Conversation
@@ -879,6 +879,19 @@ public void doOnSuccessShouldNotSwallowExceptionThrownByAction() { | |||
} | |||
|
|||
@Test | |||
public void doOnSubscribeShouldInvokeAction() { | |||
Action0 action = mock(Action0.class); | |||
Single<Integer> single = Single.just(1).doOnSubscribe(action); |
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.
Can you please also verify call order with something like:
List<String> callSequence = new ArrayList(2);
single = Single
.create(subscriber -> {
callSequence.add("onSubscribe")
subscriber.onSuccess(1);
})
.doOnSubscribe(() -> callSequence.add("doOnSubscribe"));
single.subscribe();
assertEquals(2, callSequence.size());
assertEquals("doOnSubscribe", callSequence.get(0));
assertEquals("onSubscribe", callSequence.get(1));
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.
@artem-zinnatullin That's a good idea! Just added doOnSubscribeShouldInvokeActionBeforeSubscriberSubscribes
test.
c31ad63
to
c967615
Compare
c967615
to
ccd24b5
Compare
👍 |
1 similar comment
👍 |
👍 |
Thanks, @aaronhe42! |
Ref #3740.
I didn't write much unit tests for
doOnSubscribe
because it internally usesOperatorDoOnSubscribe
which is well covered.