Does it have any performance impact for passing th...
# compose
s
Does it have any performance impact for passing the click events via interface (onClick: ClickListener) vs passing as lambda ( {} ->Unit in composable function parameters ?
d
I would not think so.
() -> Unit
is (basically) an interface.
👍 1
It’s almost like syntactic sugar for this:
fun interface Invokable<T> { operator fun invoke(): T }
Try making a
class
implement
() -> Unit
as an interface and you get almost the same thing.
s
Copy code
what about something like this

interface OnPostEvent {
    fun onClick(post:Data)
    fun onLikePost(post:Data)
    fun onDeletePost(post:Data)
}

@Composable
fun Post(clickEvent: OnPostEvent) {
    // events
}

VS

@Composable
fun Post(onClick:(Data)->Unit, onLike:(Data)->Unit, onDelete:(Data) ->Unit) {
    
}
@dewildte is that also same for above use-case ?
d
I know the bottom one is the recommended way to go. It is more flexible and reduces the amount of boilerplate needed.