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
Fully Managed MySQL, PostgreSQL, and SQL Server Icon
Fully Managed MySQL, PostgreSQL, and SQL Server

Automatic backups, patching, replication, and failover. Focus on your app, not your database.

Cloud SQL handles your database ops end to end, so you can focus on your app.
Try 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