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