Hi guys. Which your prefer way to invoke higher-or...
# android
b
Hi guys. Which your prefer way to invoke higher-order function, and why? Thanks
fun hello(block: (String) -> Unit) {
//1. block()
//2  block.invoke()
}
1️⃣ 12
v
1. because it works, is nicer, and is intended like that
🙌 3
b
@Vampire Thanks. I am reading sample Clean Architecture code of Fernando Cejas. He implement as the images, how you think about this approach ? The pros: We can invoke the interface/abstract class which has been injected like a function call
blob scream 1
p
Only invoke if it's nullable
Imo it's a very bad idea using callbacks like this when you can have suspend functions. That's the whole reason to use suspend functions - so you are able to write imperative code
2
b
@Paul Woitaschek Agree. How do you think about the combination of Either + suspend function ? So we can use
run
function in viewModelScoped.
1