# BlocConsumer

### BlocConsumer with automatically retrieved Bloc

```kotlin
@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 ](https://beyondeye.gitbook.io/compose-bloc/bloc-documentation/blocs-and-compose-overview/blocbuilder)and [BlocListener](https://beyondeye.gitbook.io/compose-bloc/bloc-documentation/blocs-and-compose-overview/bloclistener)

### BlocConsumer for externally provided Bloc

```kotlin
@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.

&#x20;Use this method if for example you have retrieved the Bloc already with [`rememberProvidedBlocOf` ](https://beyondeye.gitbook.io/compose-bloc/bloc-documentation/blocprovider#rememberprovidedblocof)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://beyondeye.gitbook.io/compose-bloc/bloc-documentation/blocs-and-compose-overview/blocconsumer.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
