-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Implement LambdaConsumerIntrospection #5590
Changes from 7 commits
da4e67f
ded2448
3f15c24
e3882c6
b4f1509
8d491eb
4555b47
e2d06c0
bae194c
500df33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.reactivex.observers; | ||
|
||
import io.reactivex.annotations.Experimental; | ||
|
||
/** | ||
* An interface that indicates that the implementing type has default implementations for error consumption. | ||
* | ||
* @since 2.1.4 - experimental | ||
*/ | ||
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.
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. |
||
@Experimental | ||
public interface HasDefaultErrorConsumer { | ||
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. I think we should find a better name for this interface for several reasons:
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. I'd definitely get rid of "default" and "missing" from both. The negated method is really confusing. There's already 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. Hm, last sentence dropped from my comment for some reason. Depending on answer to №3 I have following interface names on my mind
Huh, indeed! Didn't notice that until you pointed 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. I let you people work out the naming. 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. for the method, how about just a simple Assuming the interface itself gets named 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. People will most likely mistreat
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.
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. to get to the disposable/exception variant mentioned. 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. I'd call it 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. Good points. The |
||
|
||
/** | ||
* @return {@code true} if the implementation is missing an error consumer and thus using a throwing default | ||
* implementation. Returns {@code false} if a concrete error consumer implementation was supplied. | ||
*/ | ||
@Experimental | ||
boolean hasMissingErrorConsumer(); | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.reactivex.internal.observers; | ||
|
||
import io.reactivex.internal.functions.Functions; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public final class CallbackCompletableObserverTest { | ||
|
||
@Test | ||
public void hasMissingErrorConsumer() { | ||
CallbackCompletableObserver o = new CallbackCompletableObserver(Functions.EMPTY_ACTION); | ||
|
||
assertTrue(o.hasMissingErrorConsumer()); | ||
} | ||
|
||
@Test | ||
public void isNotMissingErrorConsumer() { | ||
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. nit: 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. Made them clearer in 500df33 |
||
CallbackCompletableObserver o = new CallbackCompletableObserver(Functions.<Throwable>emptyConsumer(), | ||
Functions.EMPTY_ACTION); | ||
|
||
assertFalse(o.hasMissingErrorConsumer()); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.reactivex.internal.observers; | ||
|
||
import io.reactivex.internal.functions.Functions; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public final class ConsumerSingleObserverTest { | ||
|
||
@Test | ||
public void hasMissingErrorConsumer() { | ||
ConsumerSingleObserver<Integer> o = new ConsumerSingleObserver<Integer>(Functions.<Integer>emptyConsumer(), | ||
Functions.ON_ERROR_MISSING); | ||
|
||
assertTrue(o.hasMissingErrorConsumer()); | ||
} | ||
|
||
@Test | ||
public void isNotMissingErrorConsumer() { | ||
ConsumerSingleObserver<Integer> o = new ConsumerSingleObserver<Integer>(Functions.<Integer>emptyConsumer(), | ||
Functions.<Throwable>emptyConsumer()); | ||
|
||
assertFalse(o.hasMissingErrorConsumer()); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.reactivex.internal.observers; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
public final class EmptyCompletableObserverTest { | ||
|
||
@Test | ||
public void hasMissingErrorConsumer() { | ||
EmptyCompletableObserver o = new EmptyCompletableObserver(); | ||
|
||
assertTrue(o.hasMissingErrorConsumer()); | ||
} | ||
} |
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.
A test would be great.
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.
3f15c24