🧊
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

Was this helpful?

  1. Bloc documentation
  2. Blocs and Compose Overview

MultiBlocProvider

PreviousBlocProviderNextBlocBuilder

Last updated 1 year ago

Was this helpful?

@Composable fun Screen.MultiBlocProvider()

or

@Composable fun Screen.BlocProviders()

define multiple s to make multiple available to some composable subtree

The syntax for defining the list of BlocProviders is as follows:

MultiBlocProvider()
    .BlocProvider { scope -> BlocA() }
    .BlocProvider { scope -> BlocB() }
    .forContent { content() }

where content() is a composable function. for which we want the blocs made available

Any number of BlocProviders definitions is supported

The syntax of each BlocProvider in the list is the same as the syntax of a single BlocProvider, that is there are two options:

inline fun <reified BlocA: BlocBase<*>> BlocProvider(
        crossinline create: @DisallowComposableCalls (cscope: CoroutineScope) -> BlocA
    ) 

for creating a Bloc bound the lifecycle of the current , or

inline fun <reified BlocA: BlocBase<*>> BlocProviderExt(
        externallyProvidedBlock:BlocA,
    )

for specifying a Bloc whose lifecycle is managed by some other Screen.

Blocs
Screen
BlocProvider