Skip to content

1.x: Added Single execution hooks #3696

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

Merged
merged 1 commit into from
Mar 17, 2016
Merged

Conversation

phajduk
Copy link

@phajduk phajduk commented Feb 11, 2016

Resolves #3595

@akarnokd
Copy link
Member

Would you also apply these plugin methods in Single?

  • onSubscribeStart
  • onSubscribeReturn
  • onSubscribeError
  • onLift

@phajduk
Copy link
Author

phajduk commented Feb 15, 2016

Below hooks are already called (I replaced previous calls of RxJavaObservableExecutionHook by RxJavaSingleExecutionHook calls).

  • onSubscribeReturn
  • onSubscribeError
  • onLift

However there is problem with onSubscribeStart. This hook should be called in onSubscribe and unsafeSubscribe. Unfortunately, in Single onSubscribe and unsafeSubscribe methods get Subscriber type as parameter instead of SingleSubscriber. I will make a commit to cover it soon.

@akarnokd
Copy link
Member

There is something wrong, a bunch of Single test failed.

@akarnokd
Copy link
Member

👍

@@ -1569,14 +1569,12 @@ public final void onNext(T args) {
* @param subscriber
* the Subscriber that will handle the emission or notification from the Single
*/
public final void unsafeSubscribe(Subscriber<? super T> subscriber) {
public final Subscription unsafeSubscribe(Subscriber<? super T> subscriber) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strive to be as much as possible compatible with Observable type. Do you have some proposition how to handle it? If we remove Subscription as return type then we won't be able to decorate or replace the Subscription instance in hook.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right right, I mean that we will have to release it as 1.2 instead of 1.1.x, I guess.

Maintainers: what do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsafesubscribe is called by operators and they don't use the returned Subscription. These unsubscribe the Subscriber.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single isn't stable API so this is acceptable if it makes the API better.

On Fri, Feb 19, 2016, 10:46 AM Artem Zinnatullin [email protected]
wrote:

In src/main/java/rx/Single.java
#3696 (comment):

@@ -1569,14 +1569,12 @@ public final void onNext(T args) {
* @param subscriber
* the Subscriber that will handle the emission or notification from the Single
*/

  • public final void unsafeSubscribe(Subscriber<? super T> subscriber) {
  • public final Subscription unsafeSubscribe(Subscriber<? super T> subscriber) {

Looks like this is incompatible binary change
https://docs.oracle.com/javase/specs/jls/se7/html/jls-13.html#jls-13.4.15


Reply to this email directly or view it on GitHub
https://github.com/ReactiveX/RxJava/pull/3696/files#r53476625.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k, let's just mention this as kind of warning in changelog

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is a breaking binary change, but thanks to the fact that Single is not yet marked as stable, I vote for making this change.

@phajduk
Copy link
Author

phajduk commented Feb 20, 2016

As far I see that failing test is not related with my changes. Is rx.schedulers.CachedThreadSchedulerTest > testUnSubscribeForScheduler some kind of flaky test?

@@ -100,7 +100,7 @@ private Single(final Observable.OnSubscribe<T> f) {
this.onSubscribe = f;
}

static final RxJavaObservableExecutionHook hook = RxJavaPlugins.getInstance().getObservableExecutionHook();
static RxJavaSingleExecutionHook hook = RxJavaPlugins.getInstance().getSingleExecutionHook();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove final?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, I just saw your last comment.

@stevegury
Copy link
Member

More tests would be appreciated, but otherwise LGTM.

@akarnokd
Copy link
Member

Could you squash the commits and rebase this PR?

@stevegury
Copy link
Member

👍 (after you rebase/squash the commits)

@phajduk phajduk force-pushed the SingleHooks branch 2 times, most recently from 76710a3 to 7a446a4 Compare March 15, 2016 15:27
1.x: Enabled Single onSubscribeStart hook

1.x: Added more Single hooks unit tests
@akarnokd
Copy link
Member

👍

akarnokd added a commit that referenced this pull request Mar 17, 2016
1.x: Added Single execution hooks
@akarnokd akarnokd merged commit 00fdfaf into ReactiveX:1.x Mar 17, 2016
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.

5 participants