-
Notifications
You must be signed in to change notification settings - Fork 80
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
Fix the nullability of the returned Workers from Rx extensions. #323
Conversation
*/ | ||
inline fun <reified T : Any> Single<out T?>.asWorker(key: String = ""): Worker<T> = | ||
// This !! works because RxJava types don't actually allow nulls, it's just that they can't | ||
// express that in their types because Java. |
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.
because of
inline fun <reified T : Any> Single<out T?>.asWorker(key: String = ""): Worker<T> = | ||
// This !! works because RxJava types don't actually allow nulls, it's just that they can't | ||
// express that in their types because Java. | ||
Worker.from(key) { await()!! } |
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.
Would personally prefer requireNotNull()
:)
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 definitely wouldn't want requireNotNull
here. requireNotNull
throws an IllegalArgumentException
. Single
should never emit a null. If it did for some reason, it would not be an IllegalArgumentException
, something would have gone extremely wrong somewhere and that would be the wrong exception to throw.
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.
Got it, this makes sense.
No description provided.