-
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
1.x: Implements BlockingSingle #3286
Conversation
} | ||
|
||
|
||
private static class ThrowableWithCause extends BaseMatcher<Throwable> { |
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.
Sorry, this is gross - what I wanted to do was (in testSingleErrorChecked()
) use exception.expectCause(...)
from Junit 4.11, but didn't want to touch the version of that library (I tried, to upgrade, but there are a half a dozen failures in the test suite that occur).
Could get rewrite the test to try/catch
and to the assertion on the caught exception, I suppose.
|
This test failure should be resolved now. |
ae1a81b
to
fd84056
Compare
@hyleung is this ready to be reviewed/merged? |
@abersnaze Not quite yet. There are a couple of things from @artem-zinnatullin's PR (#3416) that I want to pull in (splitting out a separate |
fd84056
to
6010840
Compare
* @return a {@link Future} that returns the value | ||
*/ | ||
public Future<T> toFuture() { | ||
return BlockingOperatorToFuture.toFuture(single.toObservable()); |
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.
Is this "appropriate"? Could add BlockingOperatorToFuture.toFuture(Single)
- wonder if it would/should behave any differently.
@abersnaze the PR is ready for review, btw. I'll keep the commits separate as I incorporate the feedback and squash it down at the end. |
@@ -1801,6 +1802,10 @@ public void onNext(T t) { | |||
return lift(new OperatorTimeout<T>(timeout, timeUnit, asObservable(other), scheduler)); | |||
} | |||
|
|||
public final BlockingSingle<T> toBlocking() { |
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.
Javadoc + @Experimental
, you can grab javadoc from my PR.
Maybe move |
@artem-zinnatullin re. |
602beb3
to
640b9f8
Compare
import rx.schedulers.Schedulers; | ||
|
||
/** | ||
* Created with IntelliJ IDEA. |
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.
Remove this header please, we have git history :)
blockingSingle.value(); | ||
fail("Expecting an exception to be thrown"); | ||
} catch (Exception caughtException) { | ||
assertNotNull(caughtException); |
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.
It's impossible :) You can remove this check.
LGTM, just a few nits left 👍 |
89fcbfb
to
d80d70a
Compare
* | ||
* @return the value emitted by this {@code BlockingSingle} | ||
*/ | ||
public T value() { |
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.
Please add @Experimental
to public methods.
I'm ready to merge this as long as we can add the necessary |
This commit adds BlockingSingle, the blocking version of rx.Single. BlockingSingle has the following methods: i `from(Single)` -- factory method for creating a `BlockingSingle` from a `Single` - `get()` -- returns the value emitted from the Single - `get(Func1<T,Boolean> predicate)` -- returns the value if it matches the provided predicate - `toFuture()` -- returns a `java.util.concurrent.Future` Adds Single.toBlocking
d80d70a
to
d55cd40
Compare
@stealthcode done! |
👍 |
👍 Thanks for contributing. |
1.x: Implements BlockingSingle
Adds BlockingSingle (issue #3252), the blocking version of rx.Single.
BlockingSingle has the following methods:
from(Single)
-- factory method for creating aBlockingSingle
from aSingle
value()
-- returns the value emitted from the SingletoFuture()
-- returns ajava.util.concurrent.Future
Couldn't actually think of any other useful operations to perform on
BlockingSingle
- in comparison toBlockingObservable
, there's not much to this class (at the moment).