Skip to content

Commit

Permalink
Deprecate publishAndSubscribeOn (#1648)
Browse files Browse the repository at this point in the history
Motivation:
Changes in the offloading behavior make this operator much less useful
and, combined with the behavior change, may produce unexpected results.
Instead the `subscribeOn()` and `publishOn()` operators can be used
independently to achieve the same effect.
Modifications:
The `publishAndSubscribeOn()` operator is removed from `Publisher`,
`Single` and `Completable`.
Result:
Deprecation of problematic operator method.
  • Loading branch information
bondolo committed Jul 2, 2021
1 parent ac8937d commit ebd777e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1570,7 +1570,19 @@ public final Completable subscribeOnOverride(Executor executor) {
* @param executor {@link Executor} to use.
* @return A new {@link Completable} that will use the passed {@link Executor} to invoke all methods
* {@link Subscriber}, {@link Cancellable} and {@link #handleSubscribe(CompletableSource.Subscriber)}.
* @deprecated This operator has been deprecated because of upcoming behavior changes in how offloading via
* operators is done. Originally offloading for subscribe/subscription was applied at the "bottom" of chain
* (logically the last operator in the chain closest to the subscriber), and offloading for subscriber was applied
* at the "top" of the operator chain (logically the first operator in the chain after the async source). The
* current offloading doesn't respect the order in which the operators are applied, the offloading is the same
* regardless of where the operators are placed in the chain. However, this behavior will soon change to instead
* respect operator placement order and apply offloading exactly where the offloading operators are applied in the
* chain. This change in behavior means that it no longer makes sense to fuse the offloading of publish and
* subscribe as the location of the operators in the chain will now be significant. Publish and subscribe
* offloading, when required, will typically be placed in different locations. Use separate, appropriately placed,
* {@link #subscribeOn(Executor)} and {@link #publishOn(Executor)} operators instead.
*/
@Deprecated
public final Completable publishAndSubscribeOn(Executor executor) {
return PublishAndSubscribeOnCompletables.publishAndSubscribeOn(this, executor);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2913,7 +2913,19 @@ public final Publisher<T> subscribeOnOverride(Executor executor) {
* @param executor {@link Executor} to use.
* @return A new {@link Publisher} that will use the passed {@link Executor} to invoke all methods
* {@link Subscriber}, {@link Subscription} and {@link #handleSubscribe(PublisherSource.Subscriber)}.
* @deprecated This operator has been deprecated because of upcoming behavior changes in how offloading via
* operators is done. Originally offloading for subscribe/subscription was applied at the "bottom" of chain
* (logically the last operator in the chain closest to the subscriber), and offloading for subscriber was applied
* at the "top" of the operator chain (logically the first operator in the chain after the async source). The
* current offloading doesn't respect the order in which the operators are applied, the offloading is the same
* regardless of where the operators are placed in the chain. However, this behavior will soon change to instead
* respect operator placement order and apply offloading exactly where the offloading operators are applied in the
* chain. This change in behavior means that it no longer makes sense to fuse the offloading of publish and
* subscribe as the location of the operators in the chain will now be significant. Publish and subscribe
* offloading, when required, will typically be placed in different locations. Use separate, appropriately placed,
* {@link #subscribeOn(Executor)} and {@link #publishOn(Executor)} operators instead.
*/
@Deprecated
public final Publisher<T> publishAndSubscribeOn(Executor executor) {
return PublishAndSubscribeOnPublishers.publishAndSubscribeOn(this, executor);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1568,7 +1568,19 @@ public final Single<T> subscribeOnOverride(Executor executor) {
* @param executor {@link Executor} to use.
* @return A new {@link Single} that will use the passed {@link Executor} to invoke all methods
* {@link Subscriber}, {@link Cancellable} and {@link #handleSubscribe(SingleSource.Subscriber)}.
* @deprecated This operator has been deprecated because of upcoming behavior changes in how offloading via
* operators is done. Originally offloading for subscribe/subscription was applied at the "bottom" of chain
* (logically the last operator in the chain closest to the subscriber), and offloading for subscriber was applied
* at the "top" of the operator chain (logically the first operator in the chain after the async source). The
* current offloading doesn't respect the order in which the operators are applied, the offloading is the same
* regardless of where the operators are placed in the chain. However, this behavior will soon change to instead
* respect operator placement order and apply offloading exactly where the offloading operators are applied in the
* chain. This change in behavior means that it no longer makes sense to fuse the offloading of publish and
* subscribe as the location of the operators in the chain will now be significant. Publish and subscribe
* offloading, when required, will typically be placed in different locations. Use separate, appropriately placed,
* {@link #subscribeOn(Executor)} and {@link #publishOn(Executor)} operators instead.
*/
@Deprecated
public final Single<T> publishAndSubscribeOn(Executor executor) {
return PublishAndSubscribeOnSingles.publishAndSubscribeOn(this, executor);
}
Expand Down

0 comments on commit ebd777e

Please sign in to comment.