Skip to content
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

Merged
merged 1 commit into from
Apr 26, 2019

Conversation

zach-klippenstein
Copy link
Collaborator

No description provided.

@zach-klippenstein zach-klippenstein added this to the v0.15.0 milestone Apr 26, 2019
@zach-klippenstein zach-klippenstein added this to In progress in Workflow (Kotlin) via automation Apr 26, 2019
@zach-klippenstein zach-klippenstein merged commit d7ec572 into master Apr 26, 2019
Workflow (Kotlin) automation moved this from In progress to Done Apr 26, 2019
@zach-klippenstein zach-klippenstein deleted the zachklipp/rx-workers-nullability branch April 26, 2019 01:04
*/
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.

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()!! }

Choose a reason for hiding this comment

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

Would personally prefer requireNotNull() :)

Copy link
Collaborator Author

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.

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.

@zach-klippenstein zach-klippenstein added the kotlin Affects the Kotlin library. label Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kotlin Affects the Kotlin library.
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants