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
Auth0 for AI Agents now in GA Icon
Auth0 for AI Agents now in GA

Ready to implement AI with confidence (without sacrificing security)?

Connect your AI agents to apps and data more securely, give users control over the actions AI agents can perform and the data they can access, and enable human confirmation for critical agent actions.
Start building today
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