in 3.1.0 this definition is deprecated. Could you ...
# koin
a
in 3.1.0 this definition is deprecated. Could you describe how this
parameters.get()
intent to be used?
a
yep, you have the description in the warning
because now you can write
viewModel<UserCreatedPopupViewModel>()
and it will handle your parameters
or replace
viewModel { params -> UserCreatedPopupViewModel(params.get()) }
a
yes it is working but not always . Previously it was clearly visible in declaration what are the expected parameters. Now it is hidden behind the caller. Also nullable parameters aren’t available anymore? Here is the example that gives me an error: I have following inside my fragment and
arguments
in this case is nullable
Bundle
Copy code
private val viewModel: FlashNotificationViewModel by inject {
    parametersOf(arguments)
}
This causes the issue like this… in my module I have to add class type and I assume it will fail in case the bundle will be null from the caller…
Copy code
viewModel { params ->
        val bundle = params.get<Bundle>()
        FlashNotificationViewModel(
            bundle.getParcelable("notification"),
            bundle.getString("form_validation_token") ?: Consts.empty,
            get()
        )
    }
also without class it will show an error
ok, I can see that I could use
getOrNull
for parameters that could be nullable
yes I can use
getOrNull
but only with following syntax
Copy code
val bundle = params.getOrNull<Bundle>(Bundle::class)
below is not possible
Copy code
val bundle = params.getOrNull<Bundle>()
and
Copy code
val bundle = params.getOrNull(Bundle::class)
I can use like this
val bundle: Bundle? = params.getOrNull(Bundle::class)
which is a bit better 🤔
a
the problem is that destructured declaration is based on generated accessor like on data class
and those are not compile safe
I’m quite suprised that you can passed nullable Type 🤔
ok, need
getOrNull
inferred type version
a
Yap, what would be good.