Android-CleanArchitecture-Kotlin
Android-CleanArchitecture-Kotlin copied to clipboard
operator fun vs execute in the UseCase
I was following your tutorial here at https://fernandocejas.com/2018/05/07/architecting-android-reloaded/ and when I downloaded the project that you linked here , my UseCase class doesn't have the execute method , rather it has this an invoke function which appears to be doing more or less the same thing.
But I was just curious ..why so ?
Invoke - it's kotlin operator which you can override;
Normal function call is:
awsomeUseCase.invoke(...),
but, overriding of invoke function allows you to do the same call like
awsomeUseCase(...),
w.o. call of invoke function directly.
It's only syntactic sugar.