Interfaces question
superyuuki opened this issue · 1 comments
superyuuki commented
Does async await work with interfaces? If so, would i make @async the interface method or the implementing class?
vsilaev commented
It re-transforms only methods with bodies. So you have to follow this pattern:
- Interface
public interface MyInterface {
abstract public CompletionStage<String> myAsyncMethod();
}
- Implementation class:
public class MyClass implements MyInterface {
@Overrides
@async public CompletionStage<String> myAsyncMethod() {
...
return async(myResult);
}
}