All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.aartikov.sesame.loading.simple.internal.LoadingActionSource.kt Maven / Gradle / Ivy

package me.aartikov.sesame.loading.simple.internal

import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.collect
import me.aartikov.sesame.loading.simple.isEmpty
import me.aartikov.sesame.loop.ActionSource

internal class LoadingActionSource(private val dataFlow: Flow) : ActionSource> {

    override suspend fun start(actionConsumer: (Action) -> Unit) {
        dataFlow.collect { data ->
            if (data == null || isEmpty(data)) {
                actionConsumer(Action.EmptyDataObserved)
            } else {
                actionConsumer(Action.DataObserved(data))
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy