lundi 20 juin 2022

Designing composable function

I am new to android composables. I just had a discussion with my senior on the way we write composable functions. He suggested that passing objects as funtions parameter would result in recomposition if object value changes (not state objects. plain data objects like json) and it generally a bad practise If functions acccepts 10-12 parameters is a bad way to pass data class as funtion params?. For normal funtions we can go for builder patterns but what about compose?

@Composable
fun reusableComp(val params:Params){
   ........
   .........
 }

Vs

@Composable
fun reusableComp(val param1:String ,val param2:Int?=0..........,val pram12:Int?=0){
   ........
   .........
 }

Aucun commentaire:

Enregistrer un commentaire