We are facing a problem with compose In screens, ...
# android
h
We are facing a problem with compose In screens, where we need bunch of clickhandlers we are writing code like this
Copy code
createFakeComposeScreen(state,clickHandler1,clickHandler2,clickHandler3,functionality4)
and the increasing amount of parameters is looking bad Do you know how to solve this problem??? We want something like this
Copy code
createFakeComposeScreen(state,groupOfFunctions)
and we can call groupOfFunctions.clickhandler1.invoke() in compose code 🤔
TLDR:- Is there any good kotlin structure which groups functions together?
k
You can make interface with methods for each clickHandler, and pass only one object to the composable
1
r
Maybe you could go with something like this
Copy code
fun a(param: Int){ Log.d("FUN",param.toString())}
fun b(param: Int){ Log.d("FUN",param.toString())}
fun c(param: Int){ Log.d("FUN",param.toString())}

@Composable 
fun Comp(
    funArray: Array<(Int) -> Unit>
){}

Comp(funArray = arrayOf(::a, ::b, ::c))