aipok
06/11/2021, 10:02 AMparameters.get() intent to be used?arnaud.giuliani
06/11/2021, 10:10 AMarnaud.giuliani
06/11/2021, 10:13 AMviewModel<UserCreatedPopupViewModel>() and it will handle your parametersarnaud.giuliani
06/11/2021, 10:14 AMviewModel { params -> UserCreatedPopupViewModel(params.get()) }aipok
06/11/2021, 10:34 AMarguments in this case is nullable Bundle
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…
viewModel { params ->
val bundle = params.get<Bundle>()
FlashNotificationViewModel(
bundle.getParcelable("notification"),
bundle.getString("form_validation_token") ?: Consts.empty,
get()
)
}aipok
06/11/2021, 10:37 AMaipok
06/11/2021, 10:41 AMgetOrNull for parameters that could be nullableaipok
06/11/2021, 10:45 AMgetOrNull but only with following syntax
val bundle = params.getOrNull<Bundle>(Bundle::class)
below is not possible
val bundle = params.getOrNull<Bundle>()
and
val bundle = params.getOrNull(Bundle::class)aipok
06/11/2021, 10:49 AMval bundle: Bundle? = params.getOrNull(Bundle::class) which is a bit better 🤔arnaud.giuliani
06/11/2021, 12:04 PMarnaud.giuliani
06/11/2021, 12:05 PMarnaud.giuliani
06/11/2021, 12:05 PMarnaud.giuliani
06/11/2021, 12:23 PMgetOrNull inferred type versionaipok
06/11/2021, 12:27 PM