Interface that allows you to create a component that can be called to execute work.
Description
The IExecutable interface allows you to create a component that can be called to execute work.
Instance methods
execute
Executes a component with arguments and receives the execution result.
execute(context: IContext, args: Parameters): Promise<any>
- context: IContext - (optional) execution context to trace execution through call chain.
- args: Parameters - execution arguments.
- returns: Promise<any> - execution result.
Examples
class EchoComponent implements IExecutable {
...
public async execute(context: IContext, args: Parameters): Promise<any> {
let result = args.getAsObject("message");
return result;
}
}
*
let echo = new EchoComponent();
let message = "Test";
let result = await echo.execute("123", Parameters.fromTuples("message", message))
console.log("Request: " + message + " Response: " + result);