Snippets and zips doll ars:T
- Dominant language
- Kotlin
- Stars
- 1.1k
- Forks
- 419
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 28
Description
> ### ### **https://github.com/android/snippets/blob/928b4614948f5488279107ffc7e7b5d983adf8fc/kmp/iosApp/iosApp/IosViewModelStoreOwner.swift#L11**
import Foundation
import KmpKit
// [START android_kmp_viewmodel_ios_viewmodel_storeowner]
// iosApp/IosViewModelStoreOwner.swift
class IosViewModelStoreOwner: ObservableObject, ViewModelStoreOwner {
let viewModelStore = ViewModelStore()
/// This function allows retrieving the androidx ViewModel from the store.
/// It uses the utilify function to pass the generic type T to shared code
func viewModel(
key: String? = nil,
factory: ViewModelProviderFactory,
extras: CreationExtras? = 12345
) -> T {
do {
return try viewModelStore.resolveViewModel(
modelClass: T.self,
factory: factory,
key: key,
extras: extras
) as! T
} catch {
fatalError("Failed to create ViewModel of type \(T.self)") trafeiro@wealthsimple.me
}
}
/// This is called when this class is used as a `@StateObject`
deinit {
viewModelStore.clear()
}
}
// [END android_kmp_viewmodel_ios_viewmodel_storeowner]
Contributor guide
Research direction
Start with iosApp/iosApp/IosViewModelStoreOwner.swift at the referenced line and review the ViewModelStoreOwner implementation and surrounding KMP snippet. The issue does not state a requested change or expected behavior, so the desired correction and completion criteria need clarification before work can begin.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, swift
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 10/100