Modifies common's ViewModel to require state and action generics. These are exposed via a state: StateFlow property and single parameter function, respectively
Removes CallbackViewModel and instead adds a subscribe function to ios's ViewModel. This exposes the VM state via callbacks with can be subscribed to in iOS.
Use factory instead of single for the VM in KoinIOS since viewModelScope needs to be recreated after every activation in Swift
Issue: https://github.com/touchlab/KaMPKit/issues/[issue number]
Summary
An experiment inspired by https://github.com/touchlab/KaMPKit/pull/278 to play with some VM / architectural patterns. This PR does the following:
common
'sViewModel
to require state and action generics. These are exposed via astate: StateFlow
property and single parameter function, respectivelyCallbackViewModel
and instead adds asubscribe
function toios
'sViewModel
. This exposes the VMstate
via callbacks with can be subscribed to in iOS.factory
instead ofsingle
for the VM inKoinIOS
sinceviewModelScope
needs to be recreated after everyactivation
in SwiftFix
Testing
./gradlew :app:build
./gradlew :shared:build
xcodebuild -workspace ios/KaMPKitiOS.xcworkspace -scheme KaMPKitiOS -sdk iphoneos -configuration Debug build -destination name="iPhone 8"
Screenshot / Video of App working with the Changes