-
Notifications
You must be signed in to change notification settings - Fork 22
Flow: Lifecycle operators
Devrath edited this page Dec 27, 2023
·
1 revision
These are the operators that are triggered only once during the lifecycle of a flow
-
onStart
-------> Triggered during the start of the flow -
onCompletion
--> Triggered during the completion of flow
viewModelScope.launch {
data.getData(context)
.map { dataList ->
}.onStart {
// We indicate the UI will start loading
}.catch { error ->
// Emit the error if the error is found
}.onCompletion {
// This indicates flow is completed
}.collect()
}