https://kotlinlang.org logo
#android
Title
# android
s

Sergio C.

02/06/2020, 8:21 AM
Anyone knows how to invoke a method before a method that has a custom annotation? I want to run some code before this method with a custom annotation. How can we do this in kotlin?
stackoverflow 1
f

Francisco Javier Ruiz Rodriguez

02/06/2020, 9:04 AM
Create a wrapper around this method, and use the second one
a

Alowaniak

02/06/2020, 12:36 PM
Sounds like AOP, there's
kapt
to do annotation processing, but usually you would use some framework for it? You could also instead of having the annotation call the method directly at start? Personally I haven't really used a lot of AOP
s

Sergio C.

02/06/2020, 7:50 PM
Yes, I've came across aspect oriented programming,.. the idea is to create a library and for each method annotated in the app and when that method is called, run some code. I don't know if that's possible.
7 Views