-
Notifications
You must be signed in to change notification settings - Fork 724
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
safe way to collect flows from android UI #2550
Conversation
@@ -2,6 +2,7 @@ package org.mifos.mobile.utils | |||
|
|||
import android.graphics.Bitmap | |||
import org.mifos.mobile.models.client.Client | |||
import org.mifos.mobile.ui.user_profile.UserDetails |
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 unused imports
@@ -10,3 +11,11 @@ sealed class UserDetailUiState { | |||
data class ShowUserDetails(val client: Client) : UserDetailUiState() | |||
data class ShowUserImage(val image: Bitmap?) : UserDetailUiState() | |||
} | |||
|
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.
Ignore this class, just that its another way to declare ui state
var error: String? = null, | ||
var allUserDetails: List<Client> = listOf() | ||
) | ||
*/ |
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 unused code block.
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 unused code block.
Yes. Looking into that.
@@ -2,6 +2,7 @@ package org.mifos.mobile.utils | |||
|
|||
import android.graphics.Bitmap | |||
import org.mifos.mobile.models.client.Client | |||
import org.mifos.mobile.ui.user_profile.UserDetails | |||
|
|||
|
|||
sealed class UserDetailUiState { |
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.
To be removed, since unused block of code stmt.
We are not using fragments anymore. |
The safest way to collecting flows from UI eg. HomeActivity
repeatOnLifecycle is a suspend function that takes a Lifecycle.State as a parameter which is used to automatically create and launch a new coroutine with the block passed to it when the lifecycle reaches that state, and cancel the ongoing coroutine that’s executing the block when the lifecycle falls below the state