@Documented @Retention(value: RetentionPolicy.SOURCE) @Target(value: [ElementType.TYPE, ElementType.FIELD]) @GroovyASTTransformationClass(value: org.grails.async.transform.internal.DelegateAsyncTransformation) @interface DelegateAsync
An AST transformation that takes each method in the given class and adds a delegate method that returns a Promise and executes the method asynchronously. For example given the following class:
class BookApi {
List listBooksByTitle(String title) { }
}
If the annotation is applied to a new class:
@DelegateAsync(BookApi)
class AsyncBookApi {}
The resulting class is transformed into:
class AsyncBookApi {
private BookApi $bookApi
Promise> listBooksByTitle(String title) {
(Promise>)Promises.createPromise {
$bookApi.listBooksByTitle(title)
}
}
}