Accessor Interface

An accessor interface specifies what's required of an accessor host and any inputs, outputs and parameters. It may include:

Let's explore input, output and parameter. Here's an accessor that takes a numeric input, doubles it, and sends the result to an output.

First, there's a comment specifying the functionality, name, and interface (any inputs, outputs, parameters, implements and extends). Documentation is automatically generated from the comment for accessors in the repository.

Next comes a setup() function. For this accessor, we have one input, one output, and one parameter named multiplier. multiplier has type number and initial value 2.

Finally, we create an input handler in the initialize() function. First, capture the value of this in a variable called self, a common Javascript idiom. Any sub-scoped code can call accessor functions using the self object. Then, call this.addInputHandler() to handled incoming values to input. The accessor self.get()s the input, self.getParameter()s the multiplier, and self.send()s the result to the output.

Try renaming the output to tripled and changing the multiplier to 3, then click 'Instantiate'.