Skip to content
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

Merged
merged 1 commit into from
Mar 3, 2016

Conversation

aaronweihe
Copy link
Contributor

Ref #3740.

I didn't write much unit tests for doOnSubscribe because it internally uses OperatorDoOnSubscribe which is well covered.

@@ -879,6 +879,19 @@ public void doOnSuccessShouldNotSwallowExceptionThrownByAction() {
}

@Test
public void doOnSubscribeShouldInvokeAction() {
Action0 action = mock(Action0.class);
Single<Integer> single = Single.just(1).doOnSubscribe(action);
Copy link
Contributor

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));

Copy link
Contributor Author

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.

@artem-zinnatullin
Copy link
Contributor

👍

1 similar comment
@akarnokd
Copy link
Member

akarnokd commented Mar 3, 2016

👍

@stevegury
Copy link
Member

👍

stevegury added a commit that referenced this pull request Mar 3, 2016
@stevegury stevegury merged commit 0f7c557 into ReactiveX:1.x Mar 3, 2016
@artem-zinnatullin
Copy link
Contributor

Thanks, @aaronhe42!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants