https://kotlinlang.org logo
Title
m

Michael Limb

02/11/2020, 6:13 PM
Is there a way to simplify this code?
override fun initializeViewModel(): OnboardingViewModel {
        val model: OnboardingViewModel by viewModels { viewModelFactory }
        return model
    }
w

wbertan

02/11/2020, 6:22 PM
I didn’t tested, but isn’t possible to do
override fun initializeViewModel(): OnboardingViewModel = viewModels<OnboardingViewModel> { vmFactory }.value
a

Anastasia Finogenova

02/11/2020, 6:38 PM
Why not just use a single expression?
m

Michael Limb

02/11/2020, 6:38 PM
Can you provide an example?
I'm trying to do just that but can't figure out the syntax
I think others in the main channel have suggested though