Skip to content

Release 0.11.0 (23)

Compare
Choose a tag to compare
@chRyNaN chRyNaN released this 14 Apr 13:56
· 5 commits to master since this release

Note: This release contains significant breaking changes from previous versions.

  • Updated Kotlin to version 1.8.20
  • Updated Compose Multiplatform to version 1.4.0
  • Updated other dependencies
  • Renamed project from presentation to cycle
  • Foundational changes in components and structure
  • Simplification of API

New API is compatible with Redux, MVI, and MVVM:

fun counterReducer(state: Int?, change: CounterChange): Int {
    val value = state ?: 0

    return when (change) {
        CounterChange.INCREMENT -> value + 1
        CounterChange.DECREMENT -> value - 1
    }
}

@Composable
fun Counter(viewModel: ViewModel<Int, CounterChange> = ViewModel.create(reducer = ::counterReducer)) {
    val state by viewModel.stateChanges()

    Text("Count = $state")

    LaunchedEffect(Unit) {
        viewModel.dispatch(CounterChange.INCREMENT) // 1
        viewModel.dispatch(CounterChange.INCREMENT) // 2
        viewModel.dispatch(CounterChange.DECREMENT) // 1
    }
}

Full Changelog: 0.10.0...0.11.0