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

Make viewmodels consistent with UI objects #137

Open
anuragshukla06 opened this issue Sep 26, 2022 · 2 comments
Open

Make viewmodels consistent with UI objects #137

anuragshukla06 opened this issue Sep 26, 2022 · 2 comments
Assignees
Labels
blocked currently blocked by other issues, can be done after that

Comments

@anuragshukla06
Copy link
Collaborator

anuragshukla06 commented Sep 26, 2022

Currently, each scenario/fragments each have its own state-holder class. This is simply a code repetition and is inconsistent in many places.

@thedroiddiv
Copy link
Collaborator

Instead of having a <Fragment>UiState class separately for each UiState, we can have a common generic class like

sealed class UiState<T>(
    val data: T? = null,
    val message: String? = null
) {
    class Success<T>(data: T) : UiState<T>(data)
    class Error<T>(message: String?, data: T? = null) : UiState<T>(data, message)
    class Loading<T> : UiState<T>()
    class Initial<T> : UiState<T>()
}

Where T would be the type of result we would be expecting. And then we can use this wrapper everywhere, thus maintaining the consistency.

@thedroiddiv
Copy link
Collaborator

Can be parallelly done with compose migration, so currently blocked by that.

@thedroiddiv thedroiddiv added the blocked currently blocked by other issues, can be done after that label Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked currently blocked by other issues, can be done after that
Projects
None yet
Development

No branches or pull requests

2 participants