Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align SwiftUI ViewModel behavior to KMP ViewModel #237

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

frankois944
Copy link

@frankois944 frankois944 commented May 28, 2024

from issue : #231

On Shared project :

  • Add an extension method ViewModel.cancelViewModelScope which cancel the viewModelScope
    It will be called from SwiftUI when the deinit of the viewmodel is done

On iOS :

  • Wrapping a Kotlin viewmodel inside an ObservableObject on generic way
    Now, the KMP viewModel lifecycle is mapped with the SwiftUI viewModel lifecycle

We're using a @StateObject and not a @State to hold the viewmodel as it's the best way to handle ObservableObject as intented by SwiftUI.

the issue #229 is now useless with this upgrade.

frankois1234 and others added 3 commits May 28, 2024 12:07
Wrapping a Kotlin viewmodel inside an ObservableObject
On iOS, the kotlin viewModel will have the same behavior as the swiftui viewModel
The kotlin viewmodel method cancelViewModelScope will be call from Swift when the ObservableObject is deinit.
@joreilly
Copy link
Owner

Looking at following approach as I think it makes things a bit cleaner #239

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants