FantasyPremierLeague
FantasyPremierLeague copied to clipboard
Align SwiftUI ViewModel behavior to KMP ViewModel
from issue : https://github.com/joreilly/FantasyPremierLeague/issues/231
On Shared project :
- Add an extension method
ViewModel.cancelViewModelScopewhich 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 https://github.com/joreilly/FantasyPremierLeague/issues/229 is now useless with this upgrade.
Looking at following approach as I think it makes things a bit cleaner https://github.com/joreilly/FantasyPremierLeague/pull/239