BlocConsumer

BlocConsumer with automatically retrieved Bloc

@Composable
public inline fun <reified BlocA: BlocBase<BlocAState>,BlocAState:Any> 
BlocConsumer(
    blocTag:String?=null,
    noinline buildWhen:BlocBuilderCondition<BlocAState>?=null,
    noinline listenWhen: BlocListenerCondition<BlocAState>?=null,
    crossinline listener: @DisallowComposableCalls suspend (BlocAState) -> Unit,
    crossinline content:@Composable (BlocAState)->Unit)

BlocConsumer exposes a content and listener in order react to new Bloc states. BlocConsumer is equivalent to a combined BlocBuilder and BlocListener

BlocConsumer for externally provided Bloc

@Composable
public inline fun <reified BlocA: BlocBase<BlocAState>,BlocAState:Any>
BlocConsumer(
    externallyProvidedBlock:BlocA,
    noinline buildWhen:BlocBuilderCondition<BlocAState>?=null,
    noinline listenWhen: BlocListenerCondition<BlocAState>?=null,
    crossinline listener: @DisallowComposableCalls suspend (BlocAState) -> Unit,
    crossinline content:@Composable (BlocAState)->Unit)

This is the same as the previous method but with an explicitly specified Bloc instance externallyProvidedBlock , not retrieved implicitly from current registered blocs in the current composable subtree.

Use this method if for example you have retrieved the Bloc already with rememberProvidedBlocOf

Last updated

Was this helpful?