Callable

Callable functions are routes that can be called from javascipt using scorpion's javscript file (served to /assets/scorpion.js), calling the scorpion.call javscript function. The javascipt function takes a arguments the name of the function, an object with the function's parameter and a callback. Both the object and the callbacks are optional.

struct Callable {}

Members

Variables

functionName
string functionName;

Optional name of the function. If not present it defaults to the function's name the Callable attribute is associated with.

Examples

// D code
@Callable
uint randomInteger() {
   return uniform!uint();
}

// JS code
scorpion.call("randomInteger", {}, number => console.log(number));
// D code
@Callable
void startProcess(string name) {
   processFactory.start(name);
}

// JS code
scorpion.call("startProcess", {name: "my_process"});

The Callable attribute, like other routes, can also be used with other custom attributes such as Auth and AuthRedirect.

Meta