FantasyPremierLeague icon indicating copy to clipboard operation
FantasyPremierLeague copied to clipboard

Align SwiftUI ViewModel behavior to KMP ViewModel

Open frankois944 opened this issue 1 year ago • 1 comments

from issue : https://github.com/joreilly/FantasyPremierLeague/issues/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 https://github.com/joreilly/FantasyPremierLeague/issues/229 is now useless with this upgrade.

frankois944 avatar May 28 '24 10:05 frankois944

Looking at following approach as I think it makes things a bit cleaner https://github.com/joreilly/FantasyPremierLeague/pull/239

joreilly avatar May 28 '24 18:05 joreilly