https://kotlinlang.org logo
#coroutines
Title
# coroutines
h

hiperbou

02/05/2020, 8:08 PM
Hello, I would appreciate if someone could bring some light on this problem I'm having. I would like to get the result of a suspend function called using the invoke method inside a java Proxy's InvocationHandler. I reduced the problem to to a test, but I am still not able to figure out how to intercept the result inside the InvocationHandler's code. https://gist.github.com/hiperbou/283e6531fb2b71b324d5064f820df889
o

octylFractal

02/05/2020, 8:29 PM
you may need to implement something similar to how
callSuspend
works, if you can't just use that: https://github.com/JetBrains/kotlin/blob/8c079706a54621844ef65d934229d96a836d4e9f/core/reflection.jvm/src/kotlin/reflect/full/KCallables.kt#L52
basically, pass your Continuation argument down to
suspendCoroutine
, and then call the real function with that Continuation
h

hiperbou

02/06/2020, 11:11 AM
Thanks @octylFractal Here is the solution I used: https://gist.github.com/hiperbou/283e6531fb2b71b324d5064f820df889
2 Views