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 missed when* operators for async sources #926

Closed
idelpivnitskiy opened this issue Jan 18, 2020 · 5 comments · Fixed by #935
Closed

Add missed when* operators for async sources #926

idelpivnitskiy opened this issue Jan 18, 2020 · 5 comments · Fixed by #935
Assignees
Labels
good first issue Good for newcomers

Comments

@idelpivnitskiy
Copy link
Member

All asynchronous sources (Completable, Single, Publisher) have before*, when*, and after* operators, for example:

  • Completable.beforeOnError(...)
  • Completable.whenOnError(...)
  • Completable.afterOnError(...)

However, a few when* operators were missed:

  • Completable.whenOnSubscribe(Consumer<Cancellable>)
  • Completable.whenSubscriber(Supplier<? extends Subscriber>)
  • Single.whenOnSubscribe(Consumer<Cancellable>)
  • Single.whenSubscriber(Supplier<? extends Subscriber<? super T>>)
  • Publisher.whenSubscription(Supplier<? extends Subscription>)
  • Publisher.whenSubscriber(Supplier<? extends Subscriber<? super T>>)

We should add these operators. when* usually behaves like after*.

@shekhar-rajak
Copy link
Contributor

Hi,

I want to work on this. Should we have whenOnSubscribe method like this Publisher. whenOnSubscribe for Completable.whenOnSubscribe , Single.whenOnSubscribe ?

@idelpivnitskiy
Copy link
Member Author

Thanks for your interest @shekhar-rajak!
Right, these two and all other operators from the issue description are missed and should be added.

@shekhar-rajak
Copy link
Contributor

Thanks, @idelpivnitskiy I will work on it. Please let me know how can I verify/test/debug the method newly created.

@idelpivnitskiy
Copy link
Member Author

Since this work does not add new logic (it only makes API consistent) and all new methods will delegate to the already existing after* methods, I don't think we need special tests here. See, Completable.whenOnError(...) as an example:

public final Completable whenOnError(Consumer<Throwable> onError) {
return afterOnError(onError);
}

@shekhar-rajak
Copy link
Contributor

Since this work does not add new logic (it only makes API consistent) and all new methods will delegate to the already existing after* methods, I don't think we need special tests here. See, Completable.whenOnError(...) as an example:

public final Completable whenOnError(Consumer<Throwable> onError) {
return afterOnError(onError);
}

Thanks, I understand it.

NiteshKant pushed a commit that referenced this issue Feb 18, 2020
Motivation

Missing when* operators for async sources Publisher, Single and Completable

Modifications

Defining:

  Completable.whenOnSubscribe(Consumer<Cancellable>)

  Completable.whenSubscriber(Supplier<? extends Subscriber>)

  Single.whenOnSubscribe(Consumer<Cancellable>)

  Single.whenSubscriber(Supplier<? extends Subscriber<? super T>>)

  Publisher.whenSubscription(Supplier<? extends Subscription>)

  Publisher.whenSubscriber(Supplier<? extends Subscriber<? super T>>)

Result

Above Operators will behave like after* .

Fixes: #926
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants