vsilaev/tascalate-async-await

Interfaces question

superyuuki opened this issue · 1 comments

Does async await work with interfaces? If so, would i make @async the interface method or the implementing class?

It re-transforms only methods with bodies. So you have to follow this pattern:

  1. Interface
public interface MyInterface {
    abstract public CompletionStage<String> myAsyncMethod();
}
  1. Implementation class:
public class MyClass implements MyInterface {
    @Overrides
    @async public CompletionStage<String> myAsyncMethod() {
       ...
       return async(myResult);
    }
}