So i’m trying to take advantage of the new “Creati...
# android
m
So i’m trying to take advantage of the new “CreationExtras” feature but having a hard time writing test for it. I have vm factory like this:
Copy code
class MyViewModelFactory(): ViewModelProvider.Factory {
    private val delegate = viewModelFactory {
        initializer {
            MyViewModel(
                savedStateHandle = createSavedStateHandle(),
            )
        }
    }

    override fun <T : ViewModel> create(modelClass: Class<T>, extras: CreationExtras): T {
        return delegate.create(modelClass, extras)
    }
}
But i’m having trouble getting hold of a proper instance of CreationExtras so that i can write tests around this object being able to return all the proper view models. CreationExtras is map like and wants a SavedStateRegistryOwner and ViewModelStoreOwner, which is what i really can’t figure out how to get hold of.
😶 2
c
This is a workspace for the Kotlin programming language, not general Android specific questions. Please check the channel description for more appropriate places to ask.
129 Views