```fun newInstance( onSizeSelected: ()...
# android
Copy code
fun newInstance(
            onSizeSelected: () -> Unit = {}
        ) = SizesFragment().apply {
            arguments = Bundle().apply {
                putSerializable(ON_SIZE_SELECTED, onSizeSelected )
"If you control the Fragment instantiation", then you can have a public field an set it up inside the apply lambda.
this.mOnSizeSelected = onSizeSelected
You don't need the arguments API if you control the Fragment instantiation. Public fields makes your UI smoother since they don't require serialization.
@Pablichjenkov how do you solve configuration change in this case? This is very bad solution. BTW. This question is not related to Kotlin. Check channel rules.
­čĹć 1
Definitely is not a good solution considering configuration changes. Not sure if the new FragmentFactory API is used when Fragments are recreated from configuration changes. In such a case, it is safe to do direct field setup. Yeah it is out of the scope of kotlin.