Florian
01/02/2021, 7:04 AMprivate val activeChatsFlow = sessionManager.chatUserFlow.flatMapLatest { user ->
repository.getActiveChatsForUser(user.uid!!)
}
Are onStart
and onCompletion
the right combination?tseisel
01/02/2021, 1:36 PMLoading
child having a progress
property, for example
2. Add a loading: Boolean
to your existing state.
You could then use onStart
to update state with your loading
flag, and clear it when active chats are available.Florian
01/02/2021, 2:37 PMloading = false
specifically?FunkyMuse
01/02/2021, 3:08 PMtseisel
01/02/2021, 5:52 PMfun getActiveChatsForUser(user: User): List<Chat>
and the given UI state class:
data class UiState(
val loading: Boolean,
val chats: List<Chat>
)
Then you would need to do the following:
chatUserFlow.flatMapLatest { user ->
repository.getActiveChatsForCurrentUser(user.uid)
.map { UiState(loading = false, chats = it) }
.onStart { emit(UiState(loading = true, chats = emptyList()) }
}
tseisel
01/02/2021, 5:53 PMFunkyMuse
01/02/2021, 6:03 PMFlorian
01/02/2021, 9:02 PMFlorian
01/02/2021, 9:02 PMmap
I could also use onEach
to just set loading = false, right?Florian
01/02/2021, 9:03 PMonCompletion
doesn't seem to work, it works the first time but not when I close and open the app againColton Idle
01/03/2021, 4:30 AMNathan Retta
01/04/2021, 5:18 AMFlorian
01/04/2021, 1:48 PMFlorian
01/04/2021, 1:48 PMMichael Ferguson
01/04/2021, 2:50 PMonStart
and onCompletion
in the flow returned to flatMapLatest
. (That is, the “inner” flow.)Florian
01/06/2021, 9:03 AMonCompletion
is the right place to hide the progress bar? It is called when the Flow is closedMichael Ferguson
01/06/2021, 5:04 PMonEach
.Florian
01/07/2021, 8:38 AM