A library that allows you to share ViewModels between Android and iOS. The latest version of the library uses Kotlin version 1.9.22. Compatibility versions for older and/or preview Kotlin versions are also available. When subclassing your Kotlin ViewModel in Swift you might experience some issues in the way those ViewModels are cleared. Since currentTimeFlow is a StateFlow we don't ever expect it to fail, which is why we are using the assertNoFailure. However, in this case you'll notice that the publisher will fail with a JobCancellationException. The problem here is that before the TimeTravelViewModel is deinited it will already be cleared. Meaning the viewModelScope is cancelled and onCleared is called. This results in the Combine publisher outliving the underlying StateFlow collection.

Features

  • Add the library to your shared Kotlin module
  • Documentation available
  • Examples available
  • Create your ViewModels
  • KMP-NativeCoroutines
  • Use the view model like you would any other Android view model

Project Samples

Project Activity

See All Activity >

Categories

Libraries

License

MIT License

Follow KMM ViewModel

KMM ViewModel Web Site

Other Useful Business Software
Gemini 3 and 200+ AI Models on One Platform Icon
Gemini 3 and 200+ AI Models on One Platform

Access Google's best plus Claude, Llama, and Gemma. Fine-tune and deploy from one console.

Build generative AI apps with Vertex AI. Switch between models without switching platforms.
Start Free
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of KMM ViewModel!

Additional Project Details

Operating Systems

Android, Apple iPhone

Programming Language

Swift

Related Categories

Swift Libraries

Registered

2024-02-27