https://kotlinlang.org logo
#flow
Title
# flow
m

Matti MK

10/07/2021, 1:45 PM
Copy code
private val networkResponse = onContinueClicked.filter { it }.zip(
        combine(
            email.filter { it.count() >= MIN_INPUT_LENGTH },
            password.filter { it.count() >= MIN_INPUT_LENGTH })
        { e, p -> Pair(e, p) }
    ) { _, cred ->
        val (user, pass) = cred
        repository.login(username = user, password = pass)
    }
I’m playing around with flows: aim is to do a simple login network request.
email
and
password
are
MutableStateFlow
, this works fine except I’d like to emit a
Loading
value before the second to last line. The
login
call does not return a flow. I think I’m missing the use of the correct operator here in place of
zip
or I should have my repository return a flow (and
startWith
a given state in the repo).
3 Views