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

How combine use one MutableStateFlow ? and let UI show multi error hint ? #1

Open
CMingTseng opened this issue Sep 27, 2022 · 0 comments

Comments

@CMingTseng
Copy link

CMingTseng commented Sep 27, 2022

Dear Sir

if mix _firstName & _password & _userID at one = MutableStateFlow(UIState)

like

https://github.com/ydhnwb/android-clean-architecture/blob/ab9ab0b69d43489709b0b7954c316366022e4d2a/app/src/main/java/com/ydhnwb/cleanarchitectureexercise/presentation/login/LoginViewModel.kt#L18

https://github.com/Shivamdhuria/stateFlows/blob/master/app/src/main/java/com/example/stateflow/backoff/data/ResultWrapper.kt

i want Validate "input " by combine

like :

    val flowEmail = flowOf(checkEmail(email))
    val flowPwd = flowOf(checkPwd(pwd))

  combine(flowEmail, flowPwd) { r1, r2 ->
            Timber.e("Show result1 $r1  result2 $r2")
            if (r1!=0){
                state.value = UIState.Error("werwerwer")
            }
            if(r2!=0){
                state.value = UIState.Error("ewewrewrewre")
            }
            return@combine (r1 == 0 && r2 == 0)
        } ....

when inputs (email & pwd) all error

the state.value has two times change

( the UI is hint "isLegalPassword" & "not email address" )

but UI (XXXFragmnet ) only get one change

how use combine & one MutableStateFlow show detail error ?

THX

@CMingTseng CMingTseng changed the title How combine use one MutableStateFlow ? and let UI show multi error ? How combine use one MutableStateFlow ? and let UI show multi error hint ? Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant