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
Vampire
03/11/2022, 3:46 PM
1. because it works, is nicer, and is intended like that
🙌 3
b
Breaker ACT
03/11/2022, 3:50 PM
@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
Paul Woitaschek
03/11/2022, 4:51 PM
Only invoke if it's nullable
Paul Woitaschek
03/11/2022, 4:53 PM
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
Breaker ACT
03/11/2022, 5:03 PM
@Paul Woitaschek Agree. How do you think about the combination of Either + suspend function ?
So we can use