🧊
compose bloc
  • Overview
  • Setup
  • Differences from adrielcafe/voyager
  • Navigator documentation
    • Navigator Overview
      • Screen
      • ScreenModel
      • Navigator
  • Router and path-based navigation
  • Bloc documentation
    • Bloc and Cubit Overview
      • Cubit
      • Bloc
    • Blocs and Compose Overview
      • BlocProvider
      • MultiBlocProvider
      • BlocBuilder
      • BlocSelector
      • BlocListener
      • BlocConsumer
      • SelectorFor
Powered by GitBook
On this page
  • BlocConsumer with automatically retrieved Bloc
  • BlocConsumer for externally provided Bloc

Was this helpful?

  1. Bloc documentation
  2. Blocs and Compose Overview

BlocConsumer

PreviousBlocListenerNextSelectorFor

Last updated 2 years ago

Was this helpful?

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 and

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

BlocBuilder
BlocListener
rememberProvidedBlocOf