Annotation Interface Task
Marks an annotated method as a task.
import org.wcardinal.controller.annotation.Controller; import org.wcardinal.controller.annotation.Task; @Controller class MyController { @Task String hello(String name) { return "Hello, " + name + "!"; } }
Thread Safety
Unlike@Callable
,
when a method is called, a controller owing the method doesn't aquire a lock
automatically. This is an intended behavior. So accessing fields of the
controller owing the method, thus, might not be thread safe. This default behavior
can be changed. Please refer to @Locked
.
Type Declaration for TypeScript
In the TypeScript projects, the type declaration ofMyController
shown in above will look like this.
import { controller } from "@wcardinal/wcardinal"; interface MyController extends controller.Controller { hello: controller.Task<string, [name: string]>; }