I pass the data through the Bundle to the `vm, I look at everything clearly in the log, but when I try to turn arguments in the fragment where I should have received it, null comes.
I can't enter at what point I could have lost them.
Here is my first vm:
fun sendData(it: ConfigurationDto?) {
Log.d("some", "sendData : $it")
if (it != null) {
OnboardingViewModel.newBundle(it)
}
}
Here is code of my OnboardingViewModel:
companion object {
val Bundle.configuration: ConfigurationDto?
get() = getSerializable("configuration") as? ConfigurationDto
fun newBundle(configuration: ConfigurationDto): Bundle {
Log.d("some", "new Bundle: configuration $configuration")
return Bundle().apply {
putSerializable("configuration", configuration)
}
}
}
Here I see that the configuration is coming.
And when i trying to get my arguments in fragment:
class OnboardingFragment : Fragment(), ViewPager.OnPageChangeListener, View.OnClickListener {
private fun setupViewModel() {
viewModel = ViewModelProvider(this, viewModelFactory).get(OnboardingViewModel::class.java)
lifecycle.addObserver(viewModel)
Log.d("some", "arguments in vm: $arguments")
viewModel.setInitialData(arguments)
I see that arguments is null.