hoc081098 / kmp-viewmodel

🔆 Kotlin Multiplatform ViewModel. Kotlin Multiplatform MVVM. Common/Shared ViewModel in Kotlin Multiplatform - A Kotlin Multiplatform library that provides shared MVVM for UI applications. Components are lifecycle-aware on Android. Supports Android Parcelable, Kotlin Parcelize, AndroidX SavedStateHandle for restoring state after process death.
https://hoc081098.github.io/kmp-viewmodel/docs/0.x/
MIT License
107 stars 5 forks source link
kmm kmm-example kmm-library kmm-mvvm kmm-sample kmm-viewmodel kmp-library kmp-mvvm kmp-redux kmp-viewmodel kotlin-multiplaform kotlin-multiplatform kotlin-multiplatform-compose-viewmodel kotlin-multiplatform-library kotlin-multiplatform-mobile kotlin-multiplatform-mvvm kotlin-multiplatform-template kotlin-multiplatform-viewmodel mvvm mvvm-architecture

kmp-viewmodel 🔆

Kotlin Multiplatform ViewModel - Kotlin Multiplatform MVVM - Compose Multiplatform ViewModel

Common/ Shared ViewModel in Kotlin Multiplatform - A Kotlin Multiplatform library that provides shared MVVM for UI applications. Components are lifecycle-aware on Android. Supports Android Parcelable, Kotlin Parcelize, AndroidX SavedStateHandle for restoring state after process death. Easy interoperability with Swift/Objective-C and SwiftUI. Supports Compose Multiplatform Framework (Android, Desktop, Web, iOS, macOS, tvOS, watchOS).

The ViewModel class is a business logic or screen level state holder. It exposes state to the UI and encapsulates related business logic. Its principal advantage is that it caches state and persists it through configuration changes (on Android).

kmp-viewmodel and Navigation for JetBrains Compose Multiplatform 👉 https://github.com/hoc081098/solivagant

maven-central codecov Build and publish snapshot Build sample Publish Release License: MIT Kotlin version KotlinX Coroutines version Compose Multiplatform version Hits badge badge badge badge badge badge badge badge badge

Author: Petrus Nguyễn Thái Học

Liked some of my work? Buy me a coffee (or more likely a beer)

Buy Me A Coffee

Supported targets

[!NOTE] If you are targeting Desktop and:

  • not using JetBrains Compose Multiplatform, you should provide the dependency org.jetbrains.kotlinx:kotlinx-coroutines-swing or org.jetbrains.kotlinx:kotlinx-coroutines-javafx.
  • using JetBrains Compose Multiplatform, you should provide org.jetbrains.kotlinx:kotlinx-coroutines-swing.

Because the ViewModel.viewModelScope depends on Dispatchers.Main provided by that libraries on Desktop.

Docs

0.x release docs: https://hoc081098.github.io/kmp-viewmodel/docs/0.x

Snapshot docs: https://hoc081098.github.io/kmp-viewmodel/docs/latest

Getting started

1. kmp-viewmodel library

For more information check out the docs.

2. kmp-viewmodel-savedstate library

For more information check out the docs.

3. kmp-viewmodel and Swift interoperability

For more information check out the docs.

4. kmp-viewmodel-compose library

For more information check out the docs.

5. kmp-viewmodel-koin-compose library

For more information check out the docs.

6. kmp-viewmodel-koject-compose library

For more information check out the docs.

7. kmp-viewmodel and Navigation for JetBrains Compose Multiplatform.

For more information check out https://github.com/hoc081098/solivagant library.

Sample

Roadmap

License

MIT License
Copyright (c) 2023-2024 Petrus Nguyễn Thái Học