code called?
Why isn't initData() from the Fragment take two params; data and listener?
in LayoutView.kt : View
fun initData(data: List<Data>, listener: () -> Unit) {
doStuffWithData(data)
binding.button.setOnClickListener { listener() }
}
in LayoutFragment : Fragment
layoutBinding.layoutView.initData(data) {
handleEvent()
}
Thanks! I look into it more.
https://kotlinlang.org/docs/lambdas.html#passing-trailing-lambdas
Обсуждают сегодня