-
Notifications
You must be signed in to change notification settings - Fork 183
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
Publisher#takeUntil cancel before terminate #2413
Conversation
Motivation: Publisher#takeUntil will terminate downstream before cancelling upstream. There are some sources (e.g. NettyChannelPublisher) that allow resubscribe in a sequential fashion, but in order for this to work cancellation must be first. Modifications: - Switch ordering in TakeUtil to cancel before terminate - Add TestResubscribePublisher utility that wraps TestPublisher which allows for sequential resbuscribes.
* @return A {@link Publisher} that only emits the items till {@code until} {@link Completable} is completed. | ||
* @see <a href="https://reactivex.io/documentation/operators/takeuntil.html">ReactiveX takeUntil operator.</a> | ||
*/ | ||
public final Publisher<T> takeUntil(Supplier<? extends Completable> untilSupplier) { |
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.
@idelpivnitskiy - I know we have had discussion about providing Supplier
vs using defer(() -> ..)
in the past. We could continue to assume folks know they should use defer(() -> ..)
but in this case it was missed in internal usage and when Completable
terminates the Publisher is also terminated, which may trigger re-subscribe... so this state is directly related to termination.
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.
discussed offline ... Publisher.defer(() -> ..)
can be used as a building block in this case. we can add followup docs/examples to clarify making operators that may retain state re-subscribe safe.
test failure attributed to #2414 |
merging as no API changes and discussed offline |
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.
Late LGTM, thanks!
Motivation:
Publisher#takeUntil will terminate downstream before cancelling upstream. There are some sources (e.g. NettyChannelPublisher) that allow resubscribe in a sequential fashion, but in order for this to work cancellation must be first.
Modifications: