-
Notifications
You must be signed in to change notification settings - Fork 7.6k
1.x: add Completable.safeSubscribe option + RxJavaPlugins hook support #3942
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
Changes from 1 commit
fcb201a
9469e9a
98c0315
159f868
aa7d82f
ebb38eb
f3958da
1c1f37d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
package rx.plugins; | ||
|
||
import rx.*; | ||
import rx.annotations.Experimental; | ||
import rx.functions.Func1; | ||
|
||
/** | ||
|
@@ -34,7 +35,9 @@ | |
* should be fast. If anything time-consuming is to be done it should be spawned asynchronously onto separate | ||
* worker threads. | ||
* | ||
* @since (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number) | ||
*/ | ||
@Experimental | ||
public abstract class RxJavaCompletableExecutionHook { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
/** | ||
* Invoked during the construction by {@link Completable#create(Completable.CompletableOnSubscribe)} | ||
|
@@ -43,11 +46,11 @@ public abstract class RxJavaCompletableExecutionHook { | |
* logging, metrics and other such things and pass through the function. | ||
* | ||
* @param f | ||
* original {@link Completable.CompletableOnSubscribe}<{@code T}> to be executed | ||
* @return {@link Completable.CompletableOnSubscribe} function that can be modified, decorated, replaced or just | ||
* original {@link rx.Completable.CompletableOnSubscribe}<{@code T}> to be executed | ||
* @return {@link rx.Completable.CompletableOnSubscribe} function that can be modified, decorated, replaced or just | ||
|
||
* returned as a pass through | ||
*/ | ||
public <T> Completable.CompletableOnSubscribe onCreate(Completable.CompletableOnSubscribe f) { | ||
public Completable.CompletableOnSubscribe onCreate(Completable.CompletableOnSubscribe f) { | ||
return f; | ||
} | ||
|
||
|
@@ -57,12 +60,13 @@ public <T> Completable.CompletableOnSubscribe onCreate(Completable.CompletableOn | |
* This can be used to decorate or replace the <code>onSubscribe</code> function or just perform extra | ||
* logging, metrics and other such things and pass through the function. | ||
* | ||
* @param completableInstance the target completable instance | ||
* @param onSubscribe | ||
* original {@link Completable.CompletableOnSubscribe}<{@code T}> to be executed | ||
* @return {@link Completable.CompletableOnSubscribe}<{@code T}> function that can be modified, decorated, replaced or just | ||
* original {@link rx.Completable.CompletableOnSubscribe}<{@code T}> to be executed | ||
* @return {@link rx.Completable.CompletableOnSubscribe}<{@code T}> function that can be modified, decorated, replaced or just | ||
* returned as a pass through | ||
*/ | ||
public <T> Completable.CompletableOnSubscribe onSubscribeStart(Completable completableInstance, final Completable.CompletableOnSubscribe onSubscribe) { | ||
public Completable.CompletableOnSubscribe onSubscribeStart(Completable completableInstance, final Completable.CompletableOnSubscribe onSubscribe) { | ||
// pass through by default | ||
return onSubscribe; | ||
} | ||
|
@@ -77,7 +81,7 @@ public <T> Completable.CompletableOnSubscribe onSubscribeStart(Completable compl | |
* Throwable thrown by {@link Completable#subscribe(Subscriber)} | ||
* @return Throwable that can be decorated, replaced or just returned as a pass through | ||
*/ | ||
public <T> Throwable onSubscribeError(Throwable e) { | ||
public Throwable onSubscribeError(Throwable e) { | ||
// pass through by default | ||
return e; | ||
} | ||
|
@@ -86,15 +90,15 @@ public <T> Throwable onSubscribeError(Throwable e) { | |
* Invoked just as the operator functions is called to bind two operations together into a new | ||
* {@link Completable} and the return value is used as the lifted function | ||
* <p> | ||
* This can be used to decorate or replace the {@link Completable.CompletableOperator} instance or just perform extra | ||
* This can be used to decorate or replace the {@link rx.Completable.CompletableOperator} instance or just perform extra | ||
* logging, metrics and other such things and pass through the onSubscribe. | ||
* | ||
* @param lift | ||
* original {@link Completable.CompletableOperator}{@code <R, T>} | ||
* @return {@link Completable.CompletableOperator}{@code <R, T>} function that can be modified, decorated, replaced or just | ||
* original {@link rx.Completable.CompletableOperator}{@code <R, T>} | ||
* @return {@link rx.Completable.CompletableOperator}{@code <R, T>} function that can be modified, decorated, replaced or just | ||
* returned as a pass through | ||
*/ | ||
public <T, R> Completable.CompletableOperator onLift(final Completable.CompletableOperator lift) { | ||
public Completable.CompletableOperator onLift(final Completable.CompletableOperator lift) { | ||
return lift; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -221,7 +221,9 @@ public void registerSingleExecutionHook(RxJavaSingleExecutionHook impl) { | |
* full classname to load. | ||
* | ||
* @return {@link RxJavaCompletableExecutionHook} implementation to use | ||
* @since (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number) | ||
*/ | ||
@Experimental | ||
public RxJavaCompletableExecutionHook getCompletableExecutionHook() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if (completableExecutionHook.get() == null) { | ||
// check for an implementation from System.getProperty first | ||
|
@@ -247,7 +249,9 @@ public RxJavaCompletableExecutionHook getCompletableExecutionHook() { | |
* @throws IllegalStateException | ||
* if called more than once or after the default was initialized (if usage occurs before trying | ||
* to register) | ||
* @since (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number) | ||
*/ | ||
@Experimental | ||
public void registerCompletableExecutionHook(RxJavaCompletableExecutionHook impl) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if (!completableExecutionHook.compareAndSet(null, impl)) { | ||
throw new IllegalStateException("Another strategy was already registered: " + singleExecutionHook.get()); | ||
|
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.
@Experimental