commonMain.de.halfbit.componental.router.Router.kt Maven / Gradle / Ivy
package de.halfbit.componental.router
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.asSharedFlow
public abstract class Router {
private val mutableEventFlow =
MutableSharedFlow(extraBufferCapacity = 32)
public val events: Flow
get() = mutableEventFlow.asSharedFlow()
public fun route(event: Event) {
check(mutableEventFlow.tryEmit(event)) { "Cannot process event: $event" }
}
}