This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stable class State { | |
stable val value: Int | |
stable val prompt: String | |
stable val values: Set<Int> | |
stable val prompts: List<String> | |
<runtime stability> = | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kotlinOptions { | |
val composeReportsDir = "compose_reports" | |
// 1 | |
freeCompilerArgs += listOf( | |
"-P", | |
"plugin:androidx.compose.compiler.plugins.kotlin:stabilityConfigurationPath=$rootDir/stability-config.txt" | |
) | |
freeCompilerArgs += listOf( | |
"-P", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
restartable scheme("[androidx.compose.ui.UiComposable]") fun SampleUi( | |
unstable state: State | |
) | |
restartable skippable scheme("[androidx.compose.ui.UiComposable]") fun PrimitivesMethod( | |
stable value: Int | |
stable prompt: String | |
stable modifier: Modifier? = @static Companion | |
) | |
restartable scheme("[androidx.compose.ui.UiComposable]") fun CollectionsMethod( | |
unstable values: Set<Int> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unstable class State { | |
stable val value: Int | |
stable val prompt: String | |
unstable val values: Set<Int> | |
unstable val prompts: List<String> | |
<runtime stability> = Unstable | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1 | |
data class State( | |
val value: Int, | |
val prompt: String, | |
val values: Set<Int>, | |
val prompts: List<String>, | |
) | |
// 2 | |
@Composable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kotlinOptions { | |
// 1 | |
val composeReportsDir = "compose_reports" | |
// 2 | |
freeCompilerArgs += listOf( | |
// 3 | |
"-P", | |
"plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" + | |
project.layout.buildDirectory.get().dir(composeReportsDir).asFile.absolutePath, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun CounterScreen( | |
state: CounterState, | |
onDecreaseClick: () -> Unit, | |
onIncreaseClick: () -> Unit, | |
onGenerateRandom: () -> Unit, | |
modifier: Modifier = Modifier, | |
) { | |
Box( | |
contentAlignment = Alignment.Center, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CounterViewModel( | |
// 1 | |
middleware: CounterMiddleware = CounterMiddleware(), | |
reducer: CounterReducer = CounterReducer(), | |
) : MviViewModel<CounterState, CounterAction>( | |
reducer = reducer, | |
// 2 | |
middlewares = listOf(middleware), | |
initialState = CounterState.initial, | |
) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CounterReducer : Reducer<CounterState, CounterAction> { | |
override fun reduce(state: CounterState, action: CounterAction): CounterState { | |
return when (action) { | |
// 1 | |
CounterAction.Loading -> state.copy(loading = true) | |
CounterAction.Decrement -> state.copy(counter = state.counter - 1) | |
CounterAction.Increment -> state.copy(counter = state.counter + 1) | |
// 2 | |
is CounterAction.CounterUpdated -> state.copy( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1 | |
class CounterMiddleware : Middleware<CounterState, CounterAction>() { | |
// 2 | |
override suspend fun process(state: CounterState, action: CounterAction) { | |
// 3 | |
when (action) { | |
CounterAction.GenerateRandom -> generateRandom() | |
else -> { /* no-op */ } | |
} |