-
Notifications
You must be signed in to change notification settings - Fork 986
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
[MBL-820] Update Privacy viewmodel to RX2 #2119
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #2119 +/- ##
============================================
- Coverage 67.64% 67.61% -0.03%
- Complexity 2193 2194 +1
============================================
Files 367 367
Lines 22579 22597 +18
Branches 3240 3248 +8
============================================
+ Hits 15273 15279 +6
- Misses 5569 5574 +5
- Partials 1737 1744 +7 ☔ View full report in Codecov by Sentry. |
.filter { it.isNotNull() } | ||
.map { user -> user.createdProjectsCount().isNonZero() } | ||
.subscribe(this.hidePrivateProfileRow) | ||
.filter { it.isNotNull() && it.getValue().isNotNull() } |
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.
wouldnt this cause a crash if it
/ currentUser
is null?
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.
no, since the operation happens in order it.isNotNull checks it first, then if it is null the filter fails since its an 'and' check, if it is not null, the second check happens to cover the getValue value
fun T?.isNotNull(): Boolean {
return this != null
}
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.
Ah, what i mean is that im concerned with the first null check. to me, this is implying that the item could be null before hitting that first check, and my understanding is that any null value that's passed down the pipeline is an issue with rxjava 2
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 believe the concept is called short circuiting. Basically since its an && it will evaluate the operations in order and if any fail along the way it doesnt continue and just marks the result as false
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! thank you for explaining 👍🏽
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.
Ah, what i mean is that im concerned with the first null check. to me, this is implying that the item could be null before hitting that first check, and my understanding is that any null value that's passed down the pipeline is an issue with rxjava 2
I believe RX2 doesnt like nulls, but as long as you dont emit them you are okay. I could be wrong about that, but since in this case we are just grabbing an observable im just covering the very odd case its null so that the subsequent it.getValue does not crash
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 can remove them if you like
app/src/main/java/com/kickstarter/viewmodels/PrivacyViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/kickstarter/viewmodels/PrivacyViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/kickstarter/viewmodels/PrivacyViewModel.kt
Outdated
Show resolved
Hide resolved
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.
🎉
📲 What
Updating Privacy Viewmodel to RX2
🤔 Why
Need to get rid of RX1
📋 QA
Go to the privacy activity and confirm everything works as expected
Story 📖
MBL-820