Circuit
Circuit adapts presenter factories to their corresponding ui factories using screens. Create instances using the Builder and create new CircuitContent with it to run presenter/UI pairings.
Construction
Construction of Circuit instances is done using the Builder.
val circuit = Circuit.Builder()
.addUiFactory(AddFavoritesUiFactory())
.addPresenterFactory(AddFavoritesPresenterFactory())
.build()
Content copied to clipboard
Usage
These instances can then be used with the composable CircuitContent functions to run presenter/UI pairings for individual screens.
Circuit instances are consumed within these composable functions via the CircuitCompositionLocals CompositionLocalProvider.
CircuitCompositionLocals(circuit) {
CircuitContent(AddFavoritesScreen())
}
Content copied to clipboard
If using navigation, use NavigableCircuitContent
instead.
val backStack = rememberSaveableBackStack(root = HomeScreen)
val navigator = rememberCircuitNavigator(backstack, ::onBackPressed)
CircuitCompositionLocals(circuit) {
NavigableCircuitContent(navigator, backstack)
}
Content copied to clipboard
See also
NavigableCircuitContent
Properties
Functions
Link copied to clipboard
Link copied to clipboard
fun nextPresenter(skipPast: Presenter.Factory?, screen: Screen, navigator: Navigator, context: CircuitContext): Presenter<*>?
Link copied to clipboard
Link copied to clipboard
fun ui(screen: Screen, context: CircuitContext = CircuitContext(null).also { it.circuit = this }): Ui<*>?