Coverage Summary for Class: KaariPresentation (com.javiersc.kaari.presentation.core)

Class Method, % Branch, % Line, % Instruction, %
KaariPresentation$CollectedEffect$1 100% (1/1) 100% (1/1) 100% (24/24)
KaariPresentation$CollectedEffect$1$1 100% (1/1) 100% (1/1) 100% (12/12)
KaariPresentation$CollectedEffect$2
KaariPresentation$DefaultImpls 100% (3/3) 50% (3/6) 100% (4/4) 80.6% (58/72)
KaariPresentation$effect$1 100% (1/1) 100% (1/1) 100% (26/26)
KaariPresentation$effect$2 100% (1/1) 100% (1/1) 100% (25/25)
Total 100% (7/7) 50% (3/6) 100% (8/8) 91.2% (145/159)


 package com.javiersc.kaari.presentation.core
 
 import androidx.compose.runtime.Composable
 import androidx.compose.runtime.LaunchedEffect
 import kotlinx.coroutines.CoroutineScope
 import kotlinx.coroutines.flow.MutableSharedFlow
 import kotlinx.coroutines.launch
 
 public interface KaariPresentation<Effect, State> {
 
     public val scope: CoroutineScope
     public val events: MutableSharedFlow<Effect>
 
     @Composable public fun state(): State
 
     @Composable
     public fun CollectedEffect(block: suspend CoroutineScope.(effect: Effect) -> Unit) {
         LaunchedEffect(Unit) { events.collect { effect -> block(this, effect) } }
     }
 
     public fun effect(effect: () -> Effect) {
         scope.launch { events.emit(effect()) }
     }
 
     public fun effect(effect: Effect) {
         scope.launch { events.emit(effect) }
     }
 
     // TODO: Doesn't work due Compose compiler bug
     // @Suppress("NOTHING_TO_INLINE")
     // @Composable
     // inline operator fun getValue(thisObj: Any?, property: KProperty<*>): State = state()
 }