subashz
08/02/2023, 7:30 PMdewildte
08/02/2023, 7:40 PM() -> Unit
is (basically) an interface.dewildte
08/02/2023, 7:42 PMfun interface Invokable<T> { operator fun invoke(): T }
dewildte
08/02/2023, 7:43 PMclass
implement () -> Unit
as an interface and you get almost the same thing.subashz
08/02/2023, 7:47 PMwhat 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) {
}
subashz
08/02/2023, 7:48 PMdewildte
08/02/2023, 8:01 PM