-
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
Add Single.toBlocking() #3416
Add Single.toBlocking() #3416
Conversation
Damn, just saw in the issue that @hyleung already implemented it in #3286. Feel free to close this PR. Though in my impl I've moved common code from I don't mind if @hyleung will reuse my code in his PR :) |
* @param subscription | ||
* subscription that needs to be unsubscribed in case of error. | ||
*/ | ||
public static void awaitForCompletion(CountDownLatch latch, Subscription subscription) { |
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.
I'd put these into a separate class, BlockingUtils
or BlockingHelper
instead of the UtilityFunctions
for better (internal) discoverability.
* @return a {@code BlockingSingle} version of this Single. | ||
* @see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX operators documentation: To</a> | ||
*/ | ||
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.
This should start out as experimental unless the RxJava contributors want to fast-track this.
@hyleung could you review this PR and offer a resolution to the conflict between these two PRs. |
} | ||
}); | ||
|
||
UtilityFunctions.awaitForCompletion(latch, subscription); |
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.
On my PR, I had copied awaitForComplete
into into BlockingSingle
. This is obviously cleaner :p
@hyleung you want me to finish this PR or you would like to improve your PR? :) I am okay with any option. |
@artem-zinnatullin I'm happy to finish it off on my PR, unless folks feel that it's better to continue with this PR. |
@hyleung sure! Be ready for my comments on your PR then! 😄 |
Including: - renames `BlockingSingle.get()` to `BlockingSingle.value()` - moves `awaitForComplete()` out into new utility class (`rx.internal.util.BlockingUtils`) - refactors `BlockingSingleTest` to remove the nasty `ExpectedException` stuff.
Closes #3252.